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

Help me to write query


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

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Jan 12, 2006 2:39 pm
Reply with quote

Hi All,

I have the table in the below format (for eg)

EMPNO DATE SALARY
E1 01-01-2005 1000
E2 01-27-2005 1500
E3 01-28-2005 2000
E4 02-01-2005 2000
E5 02-20-2005 5000
E6 03-01-2005 4500

I need the output as

EMPNO DATE SALARY
E1 01-01-2005 1000
E4 02-01-2005 2000
E6 03-01-2005 4500

Like this.. ie., To Extract a data of every first day for the every month ...

Hope clear.. And i will b helpful for ur earliest response... icon_cool.gif
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Thu Jan 12, 2006 3:01 pm
Reply with quote

Try this:

Code:
SELECT EMPNO,
       DATE,
       SALARY
FROM EMPTABLE                 
WHERE                                 
SUBSTR(CHAR(DATE),4,2) = '01';


Hope this helps.
Back to top
View user's profile Send private message
nikyojin

New User


Joined: 05 Oct 2005
Posts: 94

PostPosted: Thu Jan 12, 2006 3:44 pm
Reply with quote

Hi Khamarutheen,

Code:
SELECT EMPNO,
       DATE,
       SALARY
FROM EMPTABLE                 
WHERE DAY(DATE)=01; 


Do inform if anything else is required

Regards,
Nikhil .S.
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top