MySQL Forums
Forum List  »  Portuguese

Group By Datas
Posted by: Adriano Rogeri Soares
Date: June 20, 2020 09:56PM

Boa Noite pessoal.

Segue que alguem consegue me ajudar com esse agrupamento? Os Valores vem mas não agrupados.

SELECT id_profissional,
IF(EXTRACT(MONTH FROM data) = 1, SUM(VALOR_SERVICO),0) AS JAN, IF(EXTRACT(MONTH FROM data) = 2, SUM(VALOR_SERVICO),0) AS FEV, IF(EXTRACT(MONTH FROM data) = 3, SUM(VALOR_SERVICO),0) AS MAR, IF(EXTRACT(MONTH FROM data) = 4, SUM(VALOR_SERVICO),0) AS ABR,
IF(EXTRACT(MONTH FROM data) = 5, SUM(VALOR_SERVICO),0) AS MAI, IF(EXTRACT(MONTH FROM data) = 6, SUM(VALOR_SERVICO),0) AS JUN
from agenda
where id_servico in(select id from servicos where id_job= '1') and
valor_servico>0 and
date_format(data,'%Y')='2020'
GROUP BY
id_profissional,data

Options: ReplyQuote


Subject
Views
Written By
Posted
Group By Datas
151
June 20, 2020 09:56PM
71
June 21, 2020 11:58AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.