By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,287 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,287 IT Pros & Developers. It's quick & easy.

problems with UNION

P: n/a
MC
Hi to all,

I'm working with DB2 on iSeries V5R3

I would like to know if this kind of SQL statement is possible :

select col1, count(col2) from TABLE where col2 in (select1 union select2).

I've an error : SQL0104N An unexpected token "UNION" was found
following "". Expected tokens may include: ")". SQLSTATE=42601

Thanks for your answers

Marie
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
MC wrote:
Hi to all,

I'm working with DB2 on iSeries V5R3

I would like to know if this kind of SQL statement is possible :

select col1, count(col2) from TABLE where col2 in (select1 union select2).

I've an error : SQL0104N An unexpected token "UNION" was found
following "". Expected tokens may include: ")". SQLSTATE=42601

Thanks for your answers

Marie

(select1 union select2) ??
Are select1 columns? If these are placeholders for the real subselect
please expand them, they may be relevant to answer your question.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

P: n/a
MC
Serge Rielau a écrit :
MC wrote:
Hi to all,

I'm working with DB2 on iSeries V5R3

I would like to know if this kind of SQL statement is possible :

select col1, count(col2) from TABLE where col2 in (select1 union
select2).

I've an error : SQL0104N An unexpected token "UNION" was found
following "". Expected tokens may include: ")". SQLSTATE=42601

Thanks for your answers

Marie


(select1 union select2) ??
Are select1 columns? If these are placeholders for the real subselect
please expand them, they may be relevant to answer your question.

Cheers
Serge

Sorry Serge,

select1 and select2 are 2 select statement. The complete statement looks
like this :

select FILE_STATE from COMPANY.FILEP where FILE_REF in (select
B2_FILE_REF from COMPANY.FICB2P where B2_FILE_SESSION = 1234 and
B2_FILE_APP = '01' union select NOR_FILE_REF from COMPANY.FICNOP where
NOR_FILE_SESSION = 1234 and NOR_FILE_APP = '01')

The 2 statements:
"select FILE_STATE from COMPANY.FILEP where FILE_REF in (select
B2_FILE_REF from COMPANY.FICB2P where B2_FILE_SESSION = 1234 and
B2_FILE_APP = '01')"

and

"select B2_FILE_REF from COMPANY.FICB2P where B2_FILE_SESSION = 1234 and
B2_FILE_APP = '01' union select NOR_FILE_REF from COMPANY.FICNOP where
NOR_FILE_SESSION = 1234 and NOR_FILE_APP = '01'"

works fine. So i don't understand why the complete statement don't work.

Thanks a lot for your help

Marie
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.