+ 2
SQL Query: Find the topper among the three students from the given table.
stud_code subj_code Marks 1. 1. 80 1. 2. 70 2 1. 90 2. 2. 70 3. 1. 80 3. 2. 90
15 Respostas
+ 4
still wrong remove "where"
+ 3
i am glad i could help
+ 2
select * from table
order by Marks, subj_code
+ 2
SELECT TOP 3 stud_code,
(SUM(Marks)) as Total,
(SUM(Marks)/COUNT(Marks)) as Average
FROM table
GRIUP BY stud_code
ORDER BY Average DESC
+ 2
same code just add TOP n
for your query you can do like this
select top 6 stud_code, subj_code, marks
from table
order by marks desc, subj_code asc
+ 1
ok you want to add students marks and male the list from top to bottom
one question do you want to count and her the average of just sum ???
+ 1
SELECT stud_code,
(SUM(Marks)) as Total,
(SUM(Marks)/COUNT(Marks)) as Average
FROM table
GRIUP BY stud_code
ORDER BY Average DESC
+ 1
ohkk... thanks a lot
+ 1
select stud_code, sum(marks) as total , max(marks) from table group by marks, order by marks;
0
this one is according to the query... but what if the question demands only the topper's code and sum...?
0
select stud_code, sum(marks) as total , max(marks) from table where order by marks;
0
group by marks;
0
@Melih Melik Sonmez
0
oh yes u r right thnk u
- 1
@Melik Sonmez ... thanks for the ans... but the query is to show the topper's stud_code after adding total marks of each student and the taking the max of that... hope you now understood the problem i am having here...