M
M
maks789452019-06-25 11:08:36
SQL
maks78945, 2019-06-25 11:08:36

How to group values ​​by multiple date ranges?

I have a request like this:

SELECT 
csw.f_object_number_pult, COUNT(*) 
FROM 
cs_workings AS csw 
WHERE 
csw.f_type_workings='Техническая' AND 
csw.f_date between '2019-06-01 00:00:00' AND '2019-06-25 23:59:59' 

GROUP BY csw.f_object_number_pult 
ORDER BY COUNT(*) DESC

All numbers of objects that match the conditions are pulled out, grouped and counted.
I need to add one more column in which the quantity will be calculated but for a different period, for example, in the first column for the current month, in the second for the last

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question