I am having trouble in retrieving DISTINCT records. Scenario is as follow: Right now my query is
Select a,b,c from TABLE_NAME
(COMPLEX_INNER JOIN LOGIC)
I want records where first two column values should be unique. I know this can be done by
GROUP BY
Clause. So the query will become
Select a,b,c from TABLE_NAME
(COMPLEX_INNER JOIN LOGIC)
GROUP BY a,b
But as c is not appearing in aggregate function or group by SQL server is giving following error:
Column 'c' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.