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
 
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 Default FTP options vasanthz All Other Mainframe Topics 2 Fri Aug 25, 2017 5:58 am
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Default Message in Rexx cvnlynn CLIST & REXX 9 Wed Aug 02, 2017 12:38 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am

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