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

Select with default


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

New User


Joined: 09 Feb 2009
Posts: 57
Location: India

PostPosted: Tue Oct 06, 2009 5:52 pm
Reply with quote

Hi All,

I need some help in formulating a SELECT query that should provide me with some constant values from the table.

For example:
The are four columns in the table TAB1 namely COL1, COL2, COL3.

I want all the values for COL2 keeping COL1 as "AAA" and COL3 as Current Timestamp, for a specified where condition on COL1. The resultant should be:

Code:

COL1                  COL2                  COL3
-------               ---------             -------------------
XXX                   ABC                   TIMESTAMP
XXX                   AAB                   TIMESTAMP
XXX                   AAC                   TIMESTAMP
XXX                   AAA                   TIMESTAMP


The values for COL2 should be selected on condition where COL1='YYY'
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Oct 06, 2009 6:01 pm
Reply with quote

Vivek,
You can try this.
Code:
SELECT 'AAA' AS COL1, COL2, CURRENT TIMESTAMP AS Col3
FROM TAB1 WHERE COL1 = 'YYY';
Back to top
View user's profile Send private message
VivekKhanna

New User


Joined: 09 Feb 2009
Posts: 57
Location: India

PostPosted: Tue Oct 06, 2009 6:41 pm
Reply with quote

Thanks Srihari,

I got it figured out. Thanks for the heads up.
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 Dynamically pass table name to a sele... DB2 2
No new posts Running a Job with the Default User ID JCL & VSAM 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts Change Default Scroll Setting TSO/ISPF 1
Search our Forums:

Back to Top