db2400 - JOIN tables inside a subquery in DB2 -


i'm having trouble paginating joined tables in db2. want return rows 10-30 of query contains inner join.

this works:

select * (     select row_number() on (order u4slsmn.slname) id,         u4slsmn.slno, u4slsmn.slname, u4slsmn.sllc     u4slsmn) p p.id between 10 , 30 

this not work:

select * (     select row_number() on (order u4slsmn.slname) id,         u4slsmn.slno, u4slsmn.slname, u4slsmn.sllc, u4const.c4name     u4slsmn inner join u4const on u4slsmn.slno = u4const.c4name ) p p.id between 10 , 30 

the error is:

selection error involving field *n.

note join query works correctly itself, not when it's run subquery.

how perform join inside subquery in db2?

works fine me on v7.1 tr9

here's ran:

select *  ( select rownumber() on (order vvname) id, idescr, vvname        olsdta.ioritemmst              inner join olsdta.vorvendmst on ivndno = vvndno      ) p p.id between 10 , 30; 

i prefer cte version however:

with p   ( select rownumber() on (order vvname) id, idescr, vvname      olsdta.ioritemmst            inner join olsdta.vorvendmst on ivndno = vvndno  )  select * p p.id between 10 , 30; 

finally, note @ 7.1 tr11 (7.2 tr3), ibm added support of limit , offset clauses. query re-done follows:

select        u4slsmn.slno, u4slsmn.slname, u4slsmn.sllc, u4const.c4name  u4slsmn inner join u4const on u4slsmn.slno = u4const.c4name  order u4slsmn.slname limit 20 offset 9; 

however, note limit & offset clauses supported in prepared or embedded sql. can't use them in strsql or strqmqry. believe "run sql scripts" gui interface support them. here's article limit & offset


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -