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
 

 

Find the entries where the employee has more than one DOS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sudhakarraju

New User


Joined: 05 May 2005
Posts: 29

PostPosted: Tue Mar 02, 2010 10:09 pm    Post subject: Find the entries where the employee has more than one DOS
Reply with quote

I have the below sample table

Code:

¦---¦-----------¦----¦
¦EMP¦ DOS       ¦AMT ¦
¦---¦-----------¦----¦
¦10 ¦2009-01-01 ¦10  ¦
¦10 ¦2010-03-01 ¦21  ¦
¦11 ¦2010-01-01 ¦25  ¦
¦11 ¦2010-02-01 ¦23  ¦
¦12 ¦2010-02-28 ¦25  ¦
¦13 ¦2010-02-28 ¦10  ¦
¦13 ¦2010-03-01 ¦12  ¦
¦14 ¦2009-01-01 ¦11  ¦
¦14 ¦2009-02-01 ¦10  ¦
----------------------


I need all the entries where the employee has more than one DOS
and atleast one of the DOS should be in the past one week.

in the above table EMP - 10 & 13 entries should only be in the result.
Back to top
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Mar 02, 2010 11:05 pm    Post subject:
Reply with quote

past one week = last seven days ?

1) all entries = all emp no :

Code:
select emp from tab1 A
where exists
(select * from tab1 b
 where a.emp = b.emp and b.dos <> a.dos)
and a.dos > current_date - 7 days
group by emp


2) all entries = all rows:

Code:
select * from tab1 A
where exists
(select * from tab1 b
 where a.emp = b.emp and b.dos <> a.dos)
and exists
(select * from tab1 c
 where a.emp = c.emp
    and c.dos > current_date - 7 days)
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Wed Mar 03, 2010 10:12 am    Post subject:
Reply with quote

This can also work.......

Code:
select week(dos), dos from  emptab
where week(dos) = week(current date) - 1;


Sushanth
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 find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Calling procedure with multiple entri... steve-myers PL/I & Assembler 5 Fri Jan 27, 2017 3:33 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm


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