Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select query to maximum sum of total

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2010-04-18 : 23:31:39
Dear Member
following is my table structure

stu_name subject marks
A English 30
A Science 20
A Computer 25
B English 26
B Science 30
B Computer 40
C English 25
C Science 20
C Computer 23
I have write a select query to select stu_name and maximum sum
of total marks
i have display following results

stu_name Marks
B 96

so how write a select query

thanks in advance

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-18 : 23:35:12
[code]
select top (1) stu_name, sum(marks)
from yourtable
group by stu_name
order by sum(marks) desc
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2010-04-19 : 00:01:18
Thanks Khtan
it is very good replay
bcoz i have create temp table and then select max marks and student


thnaks ones again
Go to Top of Page
   

- Advertisement -