IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

find unmatch records with query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suresh1624

New User


Joined: 21 Nov 2007
Posts: 28
Location: chennai

PostPosted: Tue Jul 28, 2009 9:18 pm
Reply with quote

Hi experts,
I have table where it has the following columns with the data given below

Dept , item , qty

208 , 12 , 30
208 , 12 , 60
208 , 12 , 90
208 , 13 , 30
208 , 13 , 55
208 , 13 , 65


The output of the query should be as follows. The unmatched quantities should apply for each item within the dept.

item , qty
12 , 55
12 , 65
13 , 60
13 , 90
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Jul 28, 2009 10:13 pm
Reply with quote

What are you tryign to achieve here ? wht is the purpose of this o/p ?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Jul 28, 2009 10:26 pm
Reply with quote

Code:


SELECT DISTINCT C.ITEM,D.QUANTITY FROM
(
SELECT * FROM TABLE  A
WHERE QUANTITY  NOT IN
(SELECT QUANTITY FROM TABLE B
WHERE ITEM <> A.ITEM)) AS C
INNER JOIN
(
SELECT * FROM TABLE  A
WHERE QUANTITY  NOT IN
(SELECT QUANTITY FROM TABLE B
WHERE ITEM <> A.ITEM)) AS D
ON C.DEPT = D.DEPT
AND C.ITEM <> D.ITEM ;



Try this code ... May work ...
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Wed Jul 29, 2009 10:28 am
Reply with quote

Hi Suresh,
Please the requirement in details .
Back to top
View user's profile Send private message
suresh1624

New User


Joined: 21 Nov 2007
Posts: 28
Location: chennai

PostPosted: Wed Jul 29, 2009 12:21 pm
Reply with quote

Hi Ashimer,

I need to sync both the items quantities. If get the data in that form i will be able to directly insert into the the table.

Looks like you are thinking table a and table b are different.but both are same. so the above query might not work. i ll confirm you
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Wed Jul 29, 2009 1:21 pm
Reply with quote

Ashimer is also thinking that both tables are same. Please replace TABLE by your table name in the query given by Ashimer and see if it works for you. You may need to tweak the query to make it work. If you face any difficulty, post the problems you encountered. Someone will be here to help you.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 29, 2009 1:34 pm
Reply with quote

Suresh, i have used only one table here ... if the correlation is confusing you , you may change the correlation names ... Run the query and let us know .. actually your requirement is getting data from different rows into a single row ... it might require a lil bit of going out of the way ...
Back to top
View user's profile Send private message
suresh1624

New User


Joined: 21 Nov 2007
Posts: 28
Location: chennai

PostPosted: Wed Jul 29, 2009 2:41 pm
Reply with quote

Thanks alot ashimer. I ll let you know soon whether it worked or not.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top