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
 

 

Select with default

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Select with default
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    Post subject:
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    Post subject:
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    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 Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm
No new posts force windows ftp client user to defa... meykh2014 All Other Mainframe Topics 0 Sun Feb 14, 2016 12:57 pm
No new posts Query to select Null row on priority RahulG31 DB2 24 Thu Jan 21, 2016 5:45 pm
No new posts Can I use sort to select sample recor... Steve Ironmonger DFSORT/ICETOOL 3 Tue Nov 10, 2015 10:02 pm


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