What is a SQL statement that can tally up the counts even including the Zeros? (all in 1 statement)
A SQL statement can give a list of the most popular gifts that are sent in a Social application, all the way to the ones that are sent 1, or 2 times, but it won't include the Zeros.
I think the same goes for getting the list of the most popular Classes that students are registering for, when the registration process for all students is 10 days and now it is the 3rd day. Again, we get the co开发者_高级运维unt but the Zeros are not there.
Is there a simple SQL statement that can show the whole list, including all the zeros?
SELECT g.gift_id, COUNT(v.gift_id) AS given_count
FROM gifts AS g
LEFT OUTER JOIN gifts_given AS v USING (gift_id)
GROUP BY g.gift_id;
精彩评论