Suppose there are multiple columns in the table. Four of them are called ID, A, B, C, and the rest... The ID column is a primary key and its values are unique. I want to create an SQL query which:
1. grouped all rows by B, C
2. sorted each group by A, ID
3. returned ID of the first row of each sorted group
I'm going to use this query as the subquery in WHERE part to filter rows of the same table (i.e. SELECT * FROM tble WHERE ID IN this_subquery).
Is that possible?