Skip to content
Advertisement

Group By clause changes the results

I have a query like

And works well, as expected, returns all records. But if i add to GROUP BY the “rec” as

The query does not return all the records and more than that, the Type is wrong. Any ideas why is this happening? I know the group only groups the records and does not influence the number of records.

Advertisement

Answer

The rec in the GROUP BY is the one in the table, not the one in your query that’s been reduced to just ‘Y’/’N’.

You would need to put in an inner query, something like:

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