Answer the question
In order to leave comments, you need to log in
MySQL. How to make grouping for each condition in where?
The actual request:
SELECT st.id, st.name, st.date_time, bs.date_time
FROM stat as st
LEFT JOIN bonus as bs ON st.date_time = bs.date_time
WHERE st.name IN('lol', 'strange')
GROUP BY MONTH(st.date_time)
Answer the question
In order to leave comments, you need to log in
SELECT st.id AS id, st.name AS name, MONTH(st.date_time) AS Month
FROM stat as st
LEFT JOIN bonus as bs ON st.date_time = bs.date_time
WHERE st.name IN('lol', 'strange')
GROUP BY st.id, st.name, MONTH(st.date_time)
Aren't you afraid that the database will say: "Well, you have queries" and freeze? Database optimizers in hell are shown execution plans for such queries.
SELECT DISTINCT st.id, st.name, MONTH(st.date_time)
FROM stat as st
LEFT JOIN bonus as bs ON st.date_time = bs.date_time
WHERE st.name IN('lol', 'strange')
ORDER BY st.id, st.name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question