Get the number of male and female premium users in the platform.
As mentioned above, We need to count the users who has the premium membership, but you are trying to sum instead of count(). And also in the WHERE clause, we need to check premium users have premium_membership value as 1 , and the value 0 is considered as non-premium user.
Table: USER
user_id name gender age country premium_membership
2000 John White M 63 AUSTRALIA 1
2001 John Andrews M 67 AUSTRALIA 1
2002 April Robinson F 60 SRILANKA 1
2003 Kathy Ryan F 81 SRILANKA 0
2004 Megan Bradshaw F 53 AUSTRALIA 1
2005 Melissa Sullivan F 45 BANGLADESH 1
there is still having lot of data in the table, but I just gave the limited data for example to get the solution related to question and the expected output format should be as follows:
Table: gender total_users
F ...
M ...
SELECT COUNT(*)
FROM USER
WHERE premium_membership = 1
Comments
Leave a comment