SQL Script to Sort Data
Budget: €8 – €30 EUR
Hello,
I need an SQL statement that sorts a table that contains id, name and timestamp.
The sort should work that way that the names are grouped according to their last timestamp. i.e. all rows of the name with the latest timestamp are shown first with descending timestamp. Then all rows of the name with the second latest timestamp are grouped and shown until all names are grouped.
You can imagine this sorting like a sorting of telegram or whatsapp messages ... all messages sorted to their names first, showing all messages of the name with the latest message first.
example:
RAW DATA
ID | name | timestamp
------------------------------------
01 | ZOE | 1000
02 | TIM | 1002
03 | TIM | 1001
04 | EVE | 1003
05 | GIL | 1004
06 | EVE | 1005
07 | GIL | 1006
08 | EVE | 1007
09 | TIM | 1008
sorts to
09 | TIM | 1008
02 | TIM | 1002
03 | TIM | 1001
08 | EVE | 1007
06 | EVE | 1005
04 | EVE | 1003
07 | GIL | 1006
05 | GIL | 1004
01 | ZOE | 1000
Please state your final quote.
I need an SQL statement that sorts a table that contains id, name and timestamp.
The sort should work that way that the names are grouped according to their last timestamp. i.e. all rows of the name with the latest timestamp are shown first with descending timestamp. Then all rows of the name with the second latest timestamp are grouped and shown until all names are grouped.
You can imagine this sorting like a sorting of telegram or whatsapp messages ... all messages sorted to their names first, showing all messages of the name with the latest message first.
example:
RAW DATA
ID | name | timestamp
------------------------------------
01 | ZOE | 1000
02 | TIM | 1002
03 | TIM | 1001
04 | EVE | 1003
05 | GIL | 1004
06 | EVE | 1005
07 | GIL | 1006
08 | EVE | 1007
09 | TIM | 1008
sorts to
09 | TIM | 1008
02 | TIM | 1002
03 | TIM | 1001
08 | EVE | 1007
06 | EVE | 1005
04 | EVE | 1003
07 | GIL | 1006
05 | GIL | 1004
01 | ZOE | 1000
Please state your final quote.