噢,还要加一句,这3句能用一个SQL写出来吗?
fromtime是时间,fee是收益,spcode是代码编号.
我想实现的功能是:
按时间分组查询收益,编号为125的收益乘以0.8,编号为103的收益乘以0.6,同时能统计出这两个编号的总收益.group by这个条件中不用spcode这个字段可以?
select fromtime,count(*),fee*0.8/100 from table where spcode="125" group by fromtime,spcode,feeselect fromtime,count(*),fee*0.6/100 from table where spcode="103" group by fromtime,spcode,feeselect fromtime,count(*),fee/100 from table group by fromtime,fee
fromtime是时间,fee是收益,spcode是代码编号.
我想实现的功能是:
按时间分组查询收益,编号为125的收益乘以0.8,编号为103的收益乘以0.6,同时能统计出这两个编号的总收益.group by这个条件中不用spcode这个字段可以?
select fromtime,count(*),fee*0.8/100 from table where spcode="125" group by fromtime,spcode,feeselect fromtime,count(*),fee*0.6/100 from table where spcode="103" group by fromtime,spcode,feeselect fromtime,count(*),fee/100 from table group by fromtime,fee
2006-06-15 feecode*0.8+feecode*0.6
2006-06-16 feecode*0.8+feecode*0.6
2006-06-17 feecode*0.8+feecode*0.6
求的是每一天的收益和不是整个月的收入和
按日期分组
select fromtime,count(*), fee = case when spcode='125' then feecode*0.8/100 when spcode='03' then feecode*0.8/100 else feecode end from table
select fromtime,count(*), fee = case when spcode='125' then feecode*0.8/100 when spcode='103' then feecode*0.6/100 else feecode end from table