user3666816
user3666816

Reputation: 1

SQL count those who expired

Im trying to find the total of those who have a membership type platinum. This is what i came up with but its not working.

SELECT COUNT (MType_ID=Platinum)
FROM Membership
WHERE (((Membership.MType_ID)=Platinum));

Upvotes: 0

Views: 68

Answers (3)

Nidal
Nidal

Reputation: 1883

try this:

SELECT COUNT (MType_ID='Platinum')
FROM Membership
WHERE Membership.MType_ID = Platinum;

Upvotes: 2

potashin
potashin

Reputation: 44581

SELECT COUNT (*)
FROM Membership
WHERE Membership.MType_ID='Platinum';

Upvotes: 3

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

You can get the total using sum() as below.

SELECT sum(MType_ID='Platinum')
FROM Membership

If you want can also use an alias for the total as

SELECT sum(MType_ID='Platinum') as total_platinum
    FROM Membership

Upvotes: 0

Related Questions