Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
satish.gorijala
Posting Yak Master
182 Posts |
Posted - 2009-07-17 : 03:35:14
|
| The data in my table is as followsFirstName GenderAABHA FAABHA FAABHA NULLAABHA MSatish MSatish NULLSatish UOutput need like thisFirstName CntAABHA 3Satish 2Here requirement is i need to count the First_names if Gender is "F" or "NULL". For example for name "AABAH", total 4 rows are there. But i need only count considering gender as "F" and "NULL". So count appears as 3 in output.I tried this query but getting wrong results.Select FirstName, Count(Gender) as SexCnt from StandardVoter Where FirstName = 'AABHA'Group by Gender having Gender is NULL or Gender = 'F'G. Satish |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-17 : 03:36:34
|
[code]select FirstName, count(Gender)from tablegroup by FirstName[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
satish.gorijala
Posting Yak Master
182 Posts |
Posted - 2009-07-17 : 03:41:19
|
Here requirement is i need to count the First_names if Gender is "F" or "NULL". For example for name "AABAH", total 4 rows are there. But i need only count considering gender as "F" and "NULL". So count appears as 3 in output.quote: Originally posted by khtan
select FirstName, count(Gender)from tablegroup by FirstName KH[spoiler]Time is always against us[/spoiler]
G. Satish |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-17 : 03:49:59
|
[code]select FirstName, count(*)from tablewhere Gender is null or Gender = 'F'group by FirstName[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|