473,378 Members | 1,138 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

problems with UNION

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
2 3070
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SM | last post by:
/* problem: Trying to get partitioned views to "prune" unneeded partitions from select statements against the partitioned view. There are 5 partitioned tables. Each with a check constraint...
3
by: Joachim Klassen | last post by:
Hi all, first apologies if this question looks the same as another one I recently posted - its a different thing but for the same szenario:-). We are having performance problems when...
1
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
6
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
18
by: __PPS__ | last post by:
Hello, I'm a university student and I'm preparing for my final today. I'm reading course notes, I found completely strange piece of code. It makes me laugh, I think the teacher needs to prepare...
6
by: alban | last post by:
Hello I have got some problems of compilation on a AIX IBM, I use the XLC compilator (And I can't install another one). I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation...
9
by: Jeremy | last post by:
I have a situation where i am trying to run two query's and retrieve one record from each query, then using Union combine them into one recordset. The First Query is strait forward and should just...
5
by: kushmanr | last post by:
hi i am having to problems: interrupt decleration doesn`t compile: void _interrupt _far terminal_isr() ....... _dos_setvect(0xC,terminal_isr) : error C4226: nonstandard extension used :...
7
by: pbd22 | last post by:
Hi. I really need some advice on fine-tuning a stored procedure that is the meat of the search logic on my site. Customers are allowed to save searches, which dumps the search logic in a table...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.