Skip to content
Advertisement

Get count column if at least one value exist – SQL

How to create a separate column for each color if at least one value exists in a group by clause? Does each color column need a separate select statement with group by clause. Thanks in advance.

For example

Advertisement

Answer

You can use conditional aggregation:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement