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

Help required to resolve the query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Need help to resolve a hard edit COBOL Programming 8
Search our Forums:

Back to Top