Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

Need to count values when a column contains 2 possible values. Stored Procedure

I have a column whose value can be either 'R' or 'O' indicating owneres and renters.

I need a sql statement that returns the total number of renters and owners in an 'Renters' column and
'Owners' column.

for Example:

Owners   Renters
1392        8372

Psuedocode:
Select from tablename
Count(Where fieldname value='O') as Owners,
Count(Where fieldname value='R') as Renters

FROM TableName

What is the syntax?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of chuckatwork
chuckatwork
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

That worked,

I just replaced the 'when when' with 'when'

Thanks,