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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


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