Answer the question
In order to leave comments, you need to log in
How to use GROUP BY to group two columns, one of which can be empty?
What is the correct way to use GROUP BY to group two columns, one of which can be empty?
For example, the structure:
command | command_text
привет |
привет | иван
GROUP BY `command` + `command_text`
or GROUP BY `command`, `command_text`
-- the results disappear with an empty `command_text``command` - varchar
`command_text` - varchar
Answer the question
In order to leave comments, you need to log in
On normal fields it seems to work without problems.
select count(*) cnt, hello, name from (
select 'привет' hello, null name
union all
select 'привет', 'иван'
union all
select 'привет', 'иван'
) tab
group by
hello, name;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question