oracle实现今年数据 去年同期和增长百分比

select c.*,round((datanow-databefore)/databefore,2)*100||‘%‘ datapercent from (select a.auth_tztype ,a.datanow,b.databefore from
(select auth_tztype,Count(auth_tztype)datanow from t_author where auth_applydate between to_date(‘2011/1/1‘,‘yyyy/mm/dd hh24:mi:ss‘)and to_date(‘2011/12/31‘,‘yyyy/mm/dd hh24:mi:ss‘) group by auth_tztype )a
 left join (select auth_tztype,Count(auth_tztype)databefore from t_author where auth_applydate between to_date(‘2010/1/1‘,‘yyyy/mm/dd hh24:mi:ss‘)and to_date(‘2010/12/31‘,‘yyyy/mm/dd hh24:mi:ss‘) group by auth_tztype  ) b on a.auth_tztype=b.auth_tztype)c

 

红色为求百分比函数
 

oracle实现今年数据 去年同期和增长百分比

上一篇:20145313张雪纯 《Java程序设计》第7周学习总结


下一篇:oracle错误ORA-00604 递归sql级别1出现错误 ora-00942 表或试图不存在 ORA-06512 在line 11