SELECT DI.DynamicIndicatorID,Di.District,tpl.filenameName ,
Di.Quarter,DI.District,DI.TFA,DI.TFB,DI.TFG,DI.TFW,DI.TFM from DynamicIndicatorsTargetsForPu
AS DI
Left Outer Join tblUploadedFiledetailsForPartners as tpl
ON
tpl.IndicatorID=DI.DynamicIndicatorID
WHERE tpl.fileID =(SELECT max(tpl.fileID) FROM tblUploadedFiledetailsForPartners tpl
WHERE tpl.IndicatorID=DI.DynamicIndicatorID AND DI.UserId=61
GROUP BY tpl.IndicatorID)
gives correct result for files but it is not showing the other records i,e if i have four rows in first table and 3 rows in second table {2 for userid=1, and one for userid=2} then it is showing the latest file for userid=1 and the right file for userid=2 , but it is not showing the other two records which do not have any file in table first.why it is so? i need all four records and show nothing in the filename column if it do not have any file