Skip to content
Advertisement

Include COUNT (including 0) of grouped records

I have a table like below

I want to count the answers for each room. That’s pretty easy, but I also want the zero values for each room and each possible answer (distinct of all answers) like shown below

I already had a hard time solving this problem, hope you guys can help me? 🙂

Advertisement

Answer

One option would be using a self join where one side of join statement containing a distinctly selected set for answers

Demo

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