Skip to content
Advertisement

Joining rows and columns in SQL

Current Result:

Desired Result:

I don’t want them to be repeated like it does in my current result.

This is my query:

I have tried without distinct too and I don’t know how to alter to get to make it look like the desired result.

Advertisement

Answer

Use aggregation:

Note that your current result should be returning NULL rather than 0. I added ELSE 0, so you explicitly get 0.

Also, don’t use single quotes for column aliases. Only use single quotes for string and date constants.

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