wood burning stoves*
The moose likes Oracle/OAS and the fly likes Group function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Group function" Watch "Group function" New topic
Author

Group function

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
I have a table named tuitionpayment with columns named enrollmentno,fullname, payment,due,discount (no primary key). I need to get max(due),sum(payment), and sum (discount) for every enrollment no.

This gets me the details of a particular enrollment no :



The above query gets me the detail of enrollmentno 1004, but, its gets me 3 rows with same date.
I need to get max(due),sum(payment), and sum (discount) for every enrollment no.something like this :


kunal
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, that seems like kind of an awkward way to do it, for a start, even if it worked. Wouldn't it be easier to just do a single Group-By query?

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks Paul Clapham for your reply.

You are right. My way was very awkward. I didn't thought of group by. Thanks once again Paul

 
 
subject: Group function
 
Similar Threads
sql problem - sum is Incorrect
How to get List elements
getting data from list returned through Hibernate
How to get multiple rows based on a single column value?
display reports in jsp