Query to Get Highest Marks Output

Question: student marks stable "sp_report"
sid maths chem phy engl
1 33 45 54 48
2 55 32 50 37
3 10 20 30 40
The required o/p is (SQL QUERY TO GET THE BELOW O/P)
sid highest_marks
1 54
2 55
3 40

Showing Answers 1 - 6 of 6 Answers

Neha

  • May 24th, 2016
 

Code
  1. SELECT max (MARKS ) FROM sp_report WHERE

  2. MARKS IN (

  3. SELECT TOP 2 * FROM sp_report

  4. ORDER BY MARKS DESC)

  Was this answer useful?  Yes

Ankit

  • Jun 4th, 2016
 

Code
  1. Select sid, max(maths,chem,phy,engl) as marks

  2. FROM stable

  3. Group by sid;

  Was this answer useful?  Yes

sandip.daptare

  • Jun 6th, 2016
 

Code
  1. SELECT SID, Max(Marksrec)

  2. FROM

  3. (SELECT Sid,

  4. maths,chems,phys,engi

  5. FROM Marks) AS st

  6. Unpivot

  7. (Marksrec FOR MARKSNO IN( maths,chems,phys,engi)) AS ddd

  8. GROUP BY SID

Suresh

  • Jun 20th, 2016
 

Code
  1. SELECT id,greatest(maths,chem,phy,engl) highest_marks FROM marks

  Was this answer useful?  Yes

Ade

  • Jun 23rd, 2016
 

Code
  1. SELECT sid,MAX(maths,chem,phy,engl) "highest_marks"

  2. FROM marks

  3. GROUP BY sid

  Was this answer useful?  Yes

Paresh

  • Jun 24th, 2016
 

Code
  1.  

  2. SELECT sid, Max(Marks) AS highest_marks

  3. FROM sp_report

  4.  Unpivot

  5. (Marks FOR value IN( maths,chem,phy,engl)) AS Score

  6. GROUP BY sid

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions