Skip to content
Advertisement

Join two tables and such that only one row from 2nd table is joined

I have Two tables, MachineWiseMaterial (Fields: McMatID) and MaterialIssueRegister (Fields: McMatID, IssueDate, IssueTime, EMR). I want the last issue date, time and EMR for each McMatID.

I can find the same for any individual McMatID using SELECT TOP 1 as follows.

But when I’m trying to join both tables, I’m not getting desired results.

The above query returns only those McMatID whose IssueDate are Max and not the max date for each McMatID.

Advertisement

Answer

You could try like this..

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement