Arrange mysql select by groups of the month

0

I'm trying to organize a return of my mysql database in months, that is, so that I have groups of the months of donations that the site that I work receives, I tried:

SELECT * , MONTH(  'DataConfirmacao' ) FROM  'doacoes' WHERE Pendente =  '1'

I tried to use Group By, but it only returned the first value not all. Table structure:

    
asked by anonymous 05.05.2018 / 18:21

1 answer

1

GROUP BY is to group by some value, what you want is ORDER BY , which is used to sort:

SELECT 
    *,
    MONTH('DataConfirmacao') 
FROM 
    'doacoes' 
WHERE 
    Pendente =  '1' 
ORDER BY 
    'DataConfirmacao';
    
05.05.2018 / 19:06