select top 1 Row_Number() Over(order by cnt desc) as SEQ, a.user_idx, a.user_hp, a.user_nick, a.test_date, b.user_idx, b.cnt,a.USER_BELONG from (select * from b2b.dbo.tb_teps_log where user_hp is not null) a left join (select user_idx, sum(quiz_cnt) as cnt from b2b.dbo.tb_thevoca_log group by user_idx ) b on a.user_idx = b.user_idx where b.cnt <> '' and a.test_date > '2017-06-01' and a.test_date < '2017-06-30 23:59:59.999' and a.TEST_TYPE = 'N' order by cnt desc, a.test_date asc
.
아까비
490