Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 How to force a select query to abend neo4u DB2 5 Mon Apr 23, 2018 1:36 pm
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts How to replace the below query? pkmurali DB2 12 Tue Feb 27, 2018 9:51 pm
No new posts How to resolve U4038? SRUTHI DRAVIDAMANI COBOL Programming 5 Sun Feb 25, 2018 12:35 pm
No new posts Receommendations required for adding ... Alan Playford JCL & VSAM 4 Wed Feb 14, 2018 4:01 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us