SQL Order By and “Not-So-Much Group”

sqlsql serversql-order-bysql-server-2000tsql

Lets say I have a table:
————————————–
| ID | DATE | GROUP | RESULT |
————————————–
| 1 | 01/06 | Group1 | 12345 |
| 2 | 01/05 | Group2 | 54321 |
| 3 | 01/04 | Group1 | 11111 |
————————————–

I want to order the result by the most recent date at the top but group the "group" column together, but still have distinct entries. The result that I want would be:

1 | 01/06 | Group1 | 12345
3 | 01/04 | Group1 | 11111
2 | 01/05 | Group2 | 54321

What would be a query to get that result?

thank you!

EDIT:

I'm using MSSQL. I'll look into translating the oracle query into MS SQL and report my results.

EDIT

SQL Server 2000, so OVER/PARTITION is not supported =[

Thank you!

Best Answer

You should specify what RDBMS you are using. This answer is for Oracle, may not work in other systems.

SELECT * FROM table
ORDER BY MAX(date) OVER (PARTITION BY group) DESC, group, date DESC