/排名查询(相同数量的排名一样,不同数量的依次递增)/
select F_PBKA_OLDSALORGID,
sum(case when t0.FBILLTYPEID='57faf492b10d31' then FQTY when t0.FBILLTYPEID='580778655b6d7d' then -FQTY end) FQTY
into #kk
from
(select FBILLTYPEID,FBILLNO,F_PBKA_DATE,F_PBKA_OLDSALORGID,fid From PBKA_t_BillHead where fid>0) t0
inner join (select F_PBKA_BHSAMOUNT,fid,FMATERIALID,FQTY From PBKA_t_GoodsDetail where fid>0) t1 on t0.fid=t1.fid
INNER JOIN T_BD_MATERIALBASE T2 ON t1.FMATERIALID=t2.FMATERIALID
where t0.FBILLTYPEID in('57faf492b10d31','580778655b6d7d')
and convert(varchar(10),t0.F_PBKA_DATE,21)=convert(varchar(10),getdate(),21)
group by F_PBKA_OLDSALORGID,FQTY
select F_PBKA_OLDSALORGID, (Select Count(distinct FQTY )+1 from #kk Where FQTY>a.FQTY) As 排名 From #kk a where F_PBKA_OLDSALORGID=@ORGID order by FQTY
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。