在实际的工作和学习中,使用以上的分析型函数,可以为用户的前端编程或者后台SQL编程带来极大的方便。
以上函数的简单示例如下:
select top 10 taxpayercode ,sum(mny_seze) as mny_seze_sukm, sum(mny_srze) as mny_srze_sum, DENSE_RANK() over( order by mny_srze_sum desc) as rank_all
from tqa_f_nsrqusb where id_mth=200702
group by taxpayercode
order by rank_all
select taxpayercode ,sum(mny_seze) as mny_seze_sukm,sum(mny_srze) as mny_srze_sum
from tqa_f_nsrqusb where id_mth=200702
group by taxpayercode order by mny_srze_sum desc
select top 10 taxpayercode ,sum(seze) as seze , NTILE(2) over ( order by seze desc) as ntile
from whtaxpayertaxbook where yr_sb=2005 and mth_sb=1
group by taxpayercode
order by seze
select top 10 taxpayercode, sum(seze) as seze, percent_rank() over (order by seze desc) as per_rank
from whtaxpayertaxbook where yr_sb=2005 and mth_sb=1
group by taxpayercode
order by seze
select top 10 taxpayercode, sum(seze) as seze, rank() over (order by seze desc) as per_rank
from whtaxpayertaxbook where yr_sb=2005 and mth_sb=1
group by taxpayercode
order by seze
注:在Oracle数据库9i以上的版本中也有类似的分析型函数,实现的功能也与此示例相似。
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交