码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2014-09-01 10:39:12      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:style   color   strong   for   数据   sp   on   c   size   

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实现今年数据 去年同期和增长百分比

标签:style   color   strong   for   数据   sp   on   c   size   

原文地址:http://www.cnblogs.com/zlqblog/p/3948684.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!