MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Select rows based on average sum

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Mon Jun 25, 2007 5:14 am    Post subject: Select rows based on average sum Reply with quote

Hi All,

Here are snapshot of a DB2 table:
Code:

Empl Num       date of run         loanamount         
1                        06/25/2007         0
1                        05/25/2007         0
1                        04/25/2007         0
--------------------------------------------
-------------------------------------
-------------------------------------------
1                        06/25/2004         1000000

Now I need to write a query to select all the rows for this emplyee since he had loan history.

Can any one let me know how to do this ?

Primary keys are : Employee num, Dept name

- Mt
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Jun 25, 2007 6:31 am    Post subject: Reply with quote

Quote:

Now I need to write a query to select all the rows for this emplyee since he had loan history. Can any one let me know how to do this ?


How do you determine he had a loan history? If the table you mentioned has more than 1 row for each Employee Num can it be considered a loan history?

Quote:

Primary keys are : Employee num, Dept name


Where is the Dept name column in the above snapshot?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Jun 25, 2007 6:33 am    Post subject: Select loan history for a specific employee Reply with quote

Martin wrote:
Now I need to write a query to select all the rows for this emplyee since he had loan history.


if DATE_OF_RUN indicates that he has a loan history
Code:

SELECT EMPL_NUM
     , DATE_OF_RUN
     , LOANAMOUNT
FROM <table>
WHERE EMPL_NUM = 1
ORDER BY 2


The ORDER BY clause will sort your output chronologically.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group