Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question on SQL query

 
Sanat Padhy
Greenhorn
Posts: 6
Java Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic