給MSSQL查詢結果追加行號

2021-05-24 14:45:41 字數 1991 閱讀 4558

selectrowno = row_number() over(partition byt1.guanlino, t1.fazhudate, t1.shijidate, t1.rukudateorder byt1.cailiaocd, t1.cailiaonm, t1.cailiaolotno, t1.qty, t1.demo),

t1.subrowno,

t1.guanlino,

t1.fazhudate,

t1.shijidate,

t1.rukudate,

t1.cailiaocd,

t1.cailiaonm,

t1.kind,

t1.cailiaolotno,

t1.qty,

t1.demo

from (selectsubrowno = row_number() over(partition bypz.guanlino, isnull(fz.fazhudate, ''), isnull(pz.shijidate, ''), isnull(rkzs.rukudate, ''), pz.cailiaocd, cm.cailiaonmorder bypz.cailiaolotno),

pz.guanlino,

isnull(fz.fazhudate, '') as fazhudate,

isnull(pz.shijidate, '') as shijidate,

isnull(rkzs.rukudate, '') as rukudate,

pz.cailiaocd,

cm.cailiaonm,

'' as kind,

pz.cailiaolotno,

isnull(pz.liangpinsum, 0) as qty,

isnull(pz.[remark ], '') as demo,

fz.gouruxiancd,

fz.gouruxiannm

from t_pinzhi pz

left join t_cailiaorkzs rkzs on rkzs.jianshouno = pz.jianshouno

and rkzs.cailiaocd = pz.cailiaocd

left join t_cailiao_mst cm on cm.cailiaocd = pz.cailiaocd

left join (select fzr.*

from t_fazhu_record fzr

inner join (select fazhuno,

cailiaocd,

max(isnull(caozuokb, 0)) as caozuokb

from t_fazhu_record

group by fazhuno, cailiaocd) rs on rs.fazhuno = fzr.fazhuno

and rs.cailiaocd = fzr.cailiaocd) fz on fz.fazhuno = pz.guanlino

and fz.cailiaocd = pz.cailiaocd

left join t_cailiaojrjc t_jr on t_jr.guanlino = pz.guanlino

left join t_youda_mst t_yr on t_yr.youdacd = t_jr.mubiaoxian

left join t_cailiaojrjc t_jc on t_jc.guanlino = pz.guanlino

left join t_youda_mst t_yc on t_yc.youdacd = t_jc.mubiaoxian

where isnull(rkzs.***, 0) <> 4

) t1

hive SQL查詢結果新增行號

用視窗函式可以解決這個問題 例 select row number over order by user id desc tab.from dws user visit month1 as tab limit 20 結果 其實要是單純想加乙個自增的行號,沒有順序要去的話 over 裡面可以空著 例 ...

給Python IDLE新增行號顯示

2 python idle編輯python程式不顯示行號 那麼應該如何操作才能讓python idle也能 顯示行號呢?2 將idlex 1.18.rar解壓縮 3 執行idlex.py啟動python idle 單擊file選單下的new file 開啟乙個python程式 4 如何禁止顯示行號 ...

Oracle給查詢結果增加序列號

在oracle中,需要加乙個序列號,首先想到是用rownum這個關鍵字,比如sql如下 select rownum,t.from table t以上sql如果不增加排序,這個資料沒有問題,一旦增加排序,序列號就錯亂了 select rownum,t.from table t order by t.s...