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
 

 

Help required to resolve the query

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

New User


Joined: 21 Jul 2008
Posts: 40
Location: pune

PostPosted: Sun Jan 11, 2009 11:45 pm    Post subject: Help required to resolve the query
Reply with quote

I am having following data in table ABC

DSNAME CRDATE CRTTIME VOLNO
A.G3544V00 12-31-2008 2:00:00 e4123

A.G3545V00 01-01-2009 2:20:00 e4163

A.G3545V00 01-01-2009 2:23:00 e4423

A.G3546V001 01-01-2009 23:23:12 e4823

C.G3593V00 02-01-2009 23:40:12 e4143

C.G3604V00 03-01-2009 23:11:12 e4199


I want to write a query like

select DSNAME ,CRDATE, CRTTIME,VOLNO fro table abc
where CRDATE = '12-31-2008' and CRTTIME > '16:00:00'

CRATE IS 'SOME DAY' WHICH MAY CHANGE
UNION

select DSNAME ,CRDATE, CRTTIME,VOLNO fro table abc
where CRDATE = '01-01-2009' and CRTTIME < '16:00:00'


CRATE IS 'NEXT DATE OF DATE ENTERED IN PREVIOUS QUERY'


tHIS UNION WILL RETUEN ONE OR MANY ROWS AND NOW IF IT RETURN MORE THAN ONE ROW
FOR E.G IN ABOVE CASE IT IS RETURNING BELOW TWO ROWS TWO ROWS THEN I WANTED TO CHECK THE LAST QUALIFIER

G3545V00 OF BOTH THE ROWS ARE SAME OR NOT. IF SAME THEN OK ELSE I WANT TO THROW ERROR MESSAGE

i WANT TO ADD THIS CONDITON IN ABOVE UNION QUERY OR ANY QUERY THAT YOU SUGGEST


A.G3545V00 01-01-2009 2:20:00 e4163

A.G3545V00 01-01-2009 2:23:00 e4423
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jan 12, 2009 1:29 am    Post subject:
Reply with quote

Is crdate defined as a date column and crtime defined as a time column? If you get multiple rows your program will have to check the last qualifier.

Code:
SELECT DSNAME ,CRDATE, CRTTIME,VOLNO FROM ABC
WHERE CRDATE = :SOMEDATE AND CRTIME <= :SOMETIME
UNION ALL
SELECT DSNAME ,CRDATE, CRTTIME,VOLNO FROM ABC
WHERE CRDATE = :SOMEDATE + 1 DAY AND CRTIME <= :SOMETIME;

Back to top
View user's profile Send private message
pdighade

New User


Joined: 21 Jul 2008
Posts: 40
Location: pune

PostPosted: Mon Jan 12, 2009 11:54 pm    Post subject: Reply to: Help required to resolve the query
Reply with quote

What will be the query if i want intersaction of these two queries because interect keyword doesn't upport DB2
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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