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 

Maximum balance without duplicates

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


Joined: 03 Jan 2006
Posts: 11
Topics: 8

PostPosted: Tue Jan 24, 2006 7:38 am    Post subject: Maximum balance without duplicates Reply with quote

Hi,

I have a table with 5 cols..
Code:

Name    SSN   Balance  opening Date  closing date

Rahul   001    10,000   12/01/06       12/01/06
Priya   002    20,000   12/01/06       12/01/06
Shukla  003    20,000   12/01/06       12/01/06
Karan   004    20,000   12/01/06       12/01/06
Kannan  005    11,000   12/01/06       12/01/06
Kiran   006    12,000   12/01/06       12/01/06

How can I get the maximum balance(no duplicates) when we give the where clause as between opening and closing dates?

Every time I am getting the maximum balance with duplicates.. How can I avoid the duplicates in this situation?
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: Tue Jan 24, 2006 8:24 am    Post subject: Reply with quote

nag77,

Try this

Code:

SELECT *                                                 
  FROM TABLE                                               
 WHERE BALANCE = (SELECT MAX(BALANCE) FROM TABLE)           
 FETCH FIRST 1 ROW ONLY                                 
 ;


Hope this helps...

Cheers

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


Joined: 03 Jan 2006
Posts: 11
Topics: 8

PostPosted: Tue Jan 24, 2006 8:45 am    Post subject: Reply with quote

THANKS KOLUSU
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