M
M
Maxim2018-04-21 13:02:59
MySQL
Maxim, 2018-04-21 13:02:59

How to make a mysql query, output by month 2 values?

There is a status field (0,1) there is a creation date field, you need to make a selection from the entire database by months with the number of status 1 and status 0

SELECT month(reviews.rev_create) as mn , count(reviews.status) as one FROM reviews GROUP BY month(reviews.rev_create), reviews.status;

it turns out but not in one line, but it is necessary in one, help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2018-04-21
@xiiicool

?

SELECT 
    month(reviews.rev_create) as mn, 
    count(IF(reviews.status = 1, 1, NULL)) as positive, 
    count(IF(reviews.status = 0, 1, NULL)) as negative
FROM 
    reviews 
GROUP BY mn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question