您好,登錄后才能下訂單哦!
/排名查詢(相同數量的排名一樣,不同數量的依次遞增)/
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。