一个复杂的交叉报表的sql写法 to bzszp(www.bzszp.533.net) ,就是根据月份,批号分组统计 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的批号是数字型的吗?SELECT periodid,decode(trunc(batchid/10),0,userpccount,0) '<10', decode(trunc(batchid/10),1,userpccount,0) '10-20', decode(trunc(batchid/10),2,userpccount,0) '20-30', decode(trunc(batchid/10),3,userpccount,0) '30-40', decode(trunc(batchid/10),4,userpccount,0) '40-50', decode(sign(trunc(batchid/10)-5),1,userpccount,0) '>50'from tbnamegroup by periodid; :)SELECT periodid,SUM(decode(trunc(batchid/10),0,userpccount,0) ' <10', SUM(decode(trunc(batchid/10),1,userpccount,0)) '10-20', SUM(decode(trunc(batchid/10),2,userpccount,0)) '20-30', SUM(decode(trunc(batchid/10),3,userpccount,0)) '30-40', SUM(decode(trunc(batchid/10),4,userpccount,0)) '40-50', SUM(decode(sign(trunc(batchid/10)-5),1,userpccount,0)) ' >50' from tbname group by periodid; bzszp(www.bzszp.533.net) 大哥的已經可以了 急!求助!如何列变行,去除重复数据 imp导入不了全部表数据报错,急 如何在pl/sql取得操作系统的类型? 谁那里有 Export工具 参数的详细解释?最好能给个全面的实例, 谢谢了!!! flashback关闭后flash_recovery_area\ORACLE\ARCHIVELOG中每天还有日志文件产生,如何删除这些日志并不让其再产生? 请教一个关于分布式数据库的问题 求asp和oracle的连接代码,谢谢 存储过程的递归调用 exp出错,只能导出表结构,导不出数据 plsql脚本里一句话看不懂,请大神指点 请教SQL语句写法 请教oracle分组统计的问题!!!
SELECT periodid,decode(trunc(batchid/10),0,userpccount,0) '<10',
decode(trunc(batchid/10),1,userpccount,0) '10-20',
decode(trunc(batchid/10),2,userpccount,0) '20-30',
decode(trunc(batchid/10),3,userpccount,0) '30-40',
decode(trunc(batchid/10),4,userpccount,0) '40-50',
decode(sign(trunc(batchid/10)-5),1,userpccount,0) '>50'
from tbname
group by periodid;
SELECT periodid,SUM(decode(trunc(batchid/10),0,userpccount,0) ' <10',
SUM(decode(trunc(batchid/10),1,userpccount,0)) '10-20',
SUM(decode(trunc(batchid/10),2,userpccount,0)) '20-30',
SUM(decode(trunc(batchid/10),3,userpccount,0)) '30-40',
SUM(decode(trunc(batchid/10),4,userpccount,0)) '40-50',
SUM(decode(sign(trunc(batchid/10)-5),1,userpccount,0)) ' >50'
from tbname
group by periodid;