Oct 13, 2004 #1 amyl Programmer Sep 16, 2002 1 US I'm trying to convert a ms sqlserver stored procedure into db2 sql. In db2, can you have a select within a select? For example, Select t1.col, Case col2 when '1' then select t2.col3 from table 2 as t2 where t1.col = t2.col else '2' END as column2 from table1 as t1
I'm trying to convert a ms sqlserver stored procedure into db2 sql. In db2, can you have a select within a select? For example, Select t1.col, Case col2 when '1' then select t2.col3 from table 2 as t2 where t1.col = t2.col else '2' END as column2 from table1 as t1
Oct 13, 2004 #2 BrianTyler IS-IT--Management Jan 29, 2003 232 GB Amyl, It should be no problem, trhough Ialways put the sub-select in brackets e.g. Select t1.col, Case col2 when '1' then (select t2.col3 from table2 t2 where t1.col = t2.col) else '2' END as column2 from table1 as t1 The sub-query must be a singleton select (i.e. must only return 1 row) Upvote 0 Downvote
Amyl, It should be no problem, trhough Ialways put the sub-select in brackets e.g. Select t1.col, Case col2 when '1' then (select t2.col3 from table2 t2 where t1.col = t2.col) else '2' END as column2 from table1 as t1 The sub-query must be a singleton select (i.e. must only return 1 row)