| Author |
A question on SQL query
|
Sanat Padhy
Greenhorn
Joined: Dec 07, 2004
Posts: 6
|
|
Is it possible to write a query for the following?
Say I have a table "Account" as below
ACCTNO -- FUNDID -- UNITS
64746-------200----------6
64746-------200----------7
64746-------201----------4
64746-------201----------6
Now I want to select such that it returns the following rows
ACCTNO -- FUNDID -- UNITS
64746-------200----------7
64746-------201----------6
In other words the funds with maximum units.
Thanks in advance.
Sanat
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26499
|
|
Sanat,
Yes. Take a look at the group by operator. You can use the max() function on one column if you list all the other columns in the group by clause.
Psuedocode:
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: A question on SQL query
|
|
|