Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Concatenating 3 columns of diff data types

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
aryanpa1

New User


Joined: 26 May 2007
Posts: 45
Location: Chennai

PostPosted: Thu Oct 29, 2009 10:24 am    Post subject: Concatenating 3 columns of diff data types
Reply with quote

Hi ,

Can you please let me know if I can concatenate 3 columns(2 integer type and 1 char type) and the result of combination to be used as where condition of in sub query. It should be like below. I am getting error when I use the below query.

EX:
Code:
  Select * from table1
  where
  (column1 || column2 || Column3) not in
             ( Select (column1 || column2 || column3) from table1
    where column4 not in ('A' , 'B')) with ur;
Back to top
View user's profile Send private message

Steve Davies

New User


Joined: 15 Oct 2009
Posts: 32
Location: UK

PostPosted: Thu Oct 29, 2009 10:59 am    Post subject:
Reply with quote

so post the error details aswell.......!
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Thu Oct 29, 2009 12:14 pm    Post subject:
Reply with quote

Hi aryanpa1,

google and you can find many such links:-

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2.doc.sqlref/rwtco.htm
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Oct 29, 2009 1:15 pm    Post subject:
Reply with quote

That is a terrible query.
You should never use
Code:
where a !! b !! c in (select a !! b !! c ...)


if you really want to use 'not in' you should write
Code:
where (a,b,c) not in (select a,b,c ...)


It is very likely that a correlated subselect is more performant.
Code:
from table1 t1 where
not exists (select 1 from table1 t2 where ...
and t1.a = t2.a and t1.b = t2.b and t1.c=t2.c)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 0 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us