2
I am using this SQL code to retrieve data, first it groups then organizes by birth date of Rows.
SELECT U.id, U.born_data, U.bold
FROM users U GROUP BY U.bold ORDER BY U.born_data DESC
However he makes a reversal, he organizes by date the Rows selected by himself (always the first), but I want him to take the last Rows of each grouping according to the date and after picking everyone make an organization again by the date, always from the most recent date to the most distant.
See an "example"
Table: users
id | bold | born_data
----------------------
1 | BR | 20/06/2015
2 | BR | 22/06/2015
3 | EN | 01/07/2015
It should return me two groupings, BR and EN however it will pick up according to the latest date of each grouping and after all or be it will show me this:
COUNT | bold | born_data
------------------------
(1) | EN | 01/07/2015 -> A DATA MAIS RECENTE DESSE AGRUPAMENTO é tambem a mais recente de todos os agrupamentos ou seja ela vem primeiro..
(2) | BR | 22/06/2015 -> A DATA MAIS RECENTE DESTE AGRUPAMENTO
it is worth mentioning that all the data must be from the last Row, as described in this problem that I found in Maicon’s answer.
" Oops, I’m gonna relive here why I got a problem that I just realized now, the MAX function works perfectly showing the date of the most recent, however it shows only the date of the most recent, I wish that it shows all the latest information. Analyze this, sqlfiddle.com/#! 9/22c35a/2 see that the ids are not the latest."
Can you give an example of the output you want to get? It’s not very clear in your question.
– bruno