您好,登錄后才能下訂單哦!
/排名查詢(相同數(shù)量的排名一樣,不同數(shù)量的依次遞增)/
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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。