Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Group function  RSS feed

 
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :
 
Sheriff
Posts: 23594
48
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Not so fast naughty spawn! I want you to know about
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!