March 22, 2011 at 12:12 pm
I have a few columns, I want to count a col where I have many values but I want to count only those values >o
Can you please help.
I wrote select count(Differenceyrs)
group by Region,Provider,QtrName
having count(differenceyrs) >0
thanks,
hai
March 22, 2011 at 12:13 pm
I'm not clear on what you need.
Can you provide the table definition you are querying?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 22, 2011 at 12:25 pm
Select Region, Provider, QtrName, sum(cnt_allmed) as AllMed, count(*) as [Not Reconciled in 18 months],
cast(0 as decimal (9,4)) as [% of all Meds not reconciled]---0 as [% of all Meds not reconciled]
into #over18_months_reconcilation from dbo.MRec_Gather_Med_Reconcilation_1
group by Region,Provider,QtrName
HAVING COUNT(DifferenceYrs)>0
so count of the designated col will be 11
I am not getting it. thanks.
------------------------------------------
DifferenceYrs
2
0
0
0
0
0
3
0
0
4
0
0
0
3
0
0
1
0
9
5
1
1
3
3
March 22, 2011 at 12:25 pm
You have no table in your select...
select count(Differenceyrs)
from MyTable
group by Region,Provider,QtrName
where differenceyrs > 0
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply