日期:2014-05-17 浏览次数:20850 次
with t as( select '20120411181706' time,'9999' manager,'0' type,'104' LV from dual union all select '20120411181706','9999','0','104' from dual union all select '20120411181706','9999','0','107' from dual union all select '20120411181706','9999','0','104' from dual union all select '20120411181734','9999','1','104' from dual union all select '20120411181734','9999','1','104' from dual union all select '20120411181734','9999','1','107' from dual union all select '20120411181734','9999','1','104' from dual )select manager,type,lv,time,count(*) from t group by time,manager,type,lv MANAGER TYPE LV TIME COUNT(*) ------- ---- --- -------------- ---------- 9999 0 104 20120411181706 3 9999 0 107 20120411181706 1 9999 1 104 20120411181734 3 9999 1 107 20120411181734 1
------解决方案--------------------
select distinct manager,type,lv,time, (select count(1) from t t1 where t1.manager=t.manager and t1.type=t.type and t1.lv=t.lv and t1.time=t.time) t_num from t
------解决方案--------------------