I have a the following table structure:
Users table:
id username
1 bob
2 john
3 harry
Posts table:
id user_id status
1 1 4
2 2 4
3 3 2
4 1 1
5 2 1
If I wanted a summary of posts per user and cols of statuses, what is the most efficient sql to generate that? Ex:
username status 4 status 2 status 1
bob 1 0 1
john 1 0 1
harry 0 1 0