sql - COUNT(DISTINCT) in subquery -


i trying retrieve each loan number, count of how many times loan number appears in each month. in cases loan number appears twice in month, want counted once in each month. test , rd columns not giving me need. here have:

select  [month], one, loannumber, two, three, four, ...  count(distinct loannumber) test, count(loannumber) on () rd   tablename lc [month] ='12-2016' group  [month], one, loannumber, two, three, four, ... 

please help!

i think need add partition by clause windowing count() expression, , remove group by, this:

select  [month], one, loannumber, two, three, four, ... count(*) on (partition month, loannumber) numberofoccurences   tablename lc [month] ='12-2016' 

Comments

Popular posts from this blog

c++ - CPP, 'X' button listener -

Get Max value from table in hibernate -

R: tune.svm return same performance for every combination of parameter -