Organize mysql select by month groups

Asked

Viewed 46 times

0

I’m trying to organize a return from my mysql bank in months , ie , so I have groups of months of donations that the site that work receives , I tried so:

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

I tried to use Group By, but it returned only the first value not all. Table structure: inserir a descrição da imagem aqui

1 answer

1


GROUP BY serves to group for some value, what you want is the ORDER BY, that serves to order:

SELECT 
    *,
    MONTH(`DataConfirmacao`) 
FROM 
    `doacoes` 
WHERE 
    Pendente =  '1' 
ORDER BY 
    `DataConfirmacao`;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.