Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

I'm being stupid, again. Sum & Count, together

$
0
0

Hi-

I thought that this should be easy and I was able to do this...nope.

i need to sum a value for each distinct count.  Having read a few post, i think i need an over() function.

select distinct
    [Training Title],
    [Training Type],
    count(CASE WHEN [user id] IS NULL THEN 0 ELSE 1 END) as 'Number',
    sum(cast([training hours] as float)) as 'Total Hours',
    count([training object id]) as 'Offerings'

-- this is duping, think i need an count([training object id]) over(PARTITION BY [TRAINING TITLE] )
from q2_2014
where [training type] = 'session'
group by
    [Training Title],
    [Training Type]



Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>