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

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -