Sort by

Is there an effective way to place an order and a group so that you get a specific item from each group (from order).

//This is the best way i have come up with. SELECT D.* FROM ( SELECT * FROM devices ORDER BY time ) AS D GROUP BY D.location 
+6
source share
2 answers

It worked for me

 SELECT * FROM (SELECT * FROM col ORDER BY col DESC,date DESC)a GROUP BY col 
+2
source
 SELECT * FROM devices GROUP BY D.location ORDER BY time --ASC or DESC default is ASC i believe 

No need for subqueries

+1
source

Source: https://habr.com/ru/post/891567/


All Articles