1. 程式人生 > >使用db2獲取某一行或者從N到M行結果

使用db2獲取某一行或者從N到M行結果

獲取第2行結果

select *from (select wuid,ROW_NUMBER() OVER(order by workseq asc) as a from WORKPROCESS where muid='702711' ) where a=2 ;

獲取第10行到第20行結果

select *from (select wuid,ROW_NUMBER() OVER(order by workseq asc) as a from WORKPROCESS where muid='702711' ) where a>=10 and a<=20 ;

使用db2 -x 命令獲取db2結果

wuid=`db2 -x "select wuid from (select wuid,ROW_NUMBER() OVER(order by workseq asc) as a from WORKPROCESS where muid='702711' ) where a=1"`
echo $wuid