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

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -