Hello i could need some help ;D. I tried on stackoverflow already, but there i did'nt get helpful/friendly answers . I have joined 2 tables and would order all results by the date, but grouped by the names (in my case clientid). So just the youngest date for each clientid is importand for the ORDER BY. It's a hard for me to explain it well so i will show you an example how it should look: name | datum -------+------------ zebra |2017-01-09 zebra |2017-01-10 zebra |2017-01-11 anton |2017-01-08 anton |2017-01-09 anton |2017-01-09 maier |2017-01-09 maier |2017-01-10 maier |2017-01-11 I tried already with (how it not should look): ORDER BY clientid, date Result: anton |2017-01-08 anton |2017-01-09 maier |2017-01-07 maier |2017-01-10 and i tried with: ORDER BY date, clientid Result: anton |2017-01-08 zebra |2017-01-09 anton |2017-01-10 I prepared a sqlliteonline with my current code and tables: https://sqliteonline.com/#fiddle-5875ebfcc9e621ae6b14e9ed5d1f48df91d5abd06f41d74206
What is wrong with the second query? It does what you want, unless you want something else entirely. The first example, the one you want, is not possible. You can't get the Z before the A, then followed by M. You can sort ascending or descending, per column.
@PoPSiCLe because i would make a site for representative where they can see the next client they have to go for and if it doesn't show the first client with the next date it is useless. And if i sort all results by dateneed only it doesn't show all products they need (maybe if the representative bring one product he could bring the other too, so he hasn't go for twice). Edit: It doesn't exist a possability somehow ? I found a function wich isn't working for me but the first example is made with it. MD5(name)