I have a select statement and in that i have a nested select statement , and in nested select statement i have aggregate function on one column , I want to add more columns with this nested select statement , and i just want to group by on one column ,
check the below query
SELECT t1.DynamicIndicatorID,t1.District,t1.Quarter,t1.District,t1.TFA,t1.TFB,t1.TFG,t1.TFW,t1.TFM,x.fileID as fileID,x.filenameName as FileName
FROM DynamicIndicatorsTargetsForPu t1
LEFT JOIN (
SELECT IndicatorID,filenameName, MAX(fileID) AS fileid
FROM tblUploadedFiledetailsForPartners group by IndicatorID
) x ON t1.DynamicIndicatorID = x.IndicatorID where t1.UserId=59
I am getting an error
Msg 8120, Level 16, State 1, Line 4
Column 'tblUploadedFiledetailsForPartners.filenameName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
I want to add more columns in Nested select statement as i have to show these columns as well but i want to group by on just one column .
Mark TaborRank #914 · 2.3K reputationPosted Jun 14, 2016, 11:06 PM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jun 20, 2016, 8:20 PM EDT
Nilesh PatelRank #6,113 · 276 reputationPosted Jun 21, 2016, 2:04 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jun 21, 2016, 3:46 AM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jun 21, 2016, 8:07 PM EDT
Nitin Sontakke
Nitin SontakkeRank #264 · 9.6K reputationPosted Jun 22, 2016, 4:19 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts