select count(*) from user where inputtime = '2012-12' group by type;
------解决方案-------------------- select count(*) from user wherer inputtime = to_date('2012-12','yyyy-mm') group by type
时间类型的字段需要转换 ------解决方案--------------------
------解决方案-------------------- SELECT type,COUNT(*) FROM testTb GROUP BY type 判断时间方法每个数据库函数不一样 ------解决方案-------------------- SELECT TRUNC(A.INPUTTYPE),TO_CHAR(A.TYPE) as TYPE,count(*) as count
FROM TABLE A GROUP BY to_char(A.TYPE),TRUNC(A.CINPUTTIME) ; ------解决方案-------------------- 你还是用这个吧 按顺序依次是type 1 - 9的值 需要你后台去联系上
SELECT type,COUNT(*) FROM userg GROUP BY type ORDER BY type ASC;
------解决方案-------------------- ORACLE 写的 写了3行
select sum(decode(type,1,cc,0)) as sg,
select sum(decode(type,2,cc,0)) as jl,
select sum(decode(type,3,cc,0)) as js from
(select type, count(*) as cc from userg where time > '2012-01' group by type)
大致这样 比那个的效率应该要高一点,希望能帮到你