By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE t
(id int, english int, hindi int, maths int, science int)
;
INSERT INTO t
(id, english, hindi, maths, science)
VALUES
(1, 80, 76, 90, 79),
(2, 8, 63, 80, 69),
(3, 50, 50, 80, 69),
(4, 80, 80, 80, 69),
(5, 80, 50, 70, 69)
;
Records: 5 Duplicates: 0 Warnings: 0
select *
from t
id | english | hindi | maths | science |
---|---|---|---|---|
1 | 80 | 76 | 90 | 79 |
2 | 8 | 63 | 80 | 69 |
3 | 50 | 50 | 80 | 69 |
4 | 80 | 80 | 80 | 69 |
5 | 80 | 50 | 70 | 69 |
select id
,total_score
from (
select id
,english+hindi+maths+science as total_score
,rank() over(order by english+hindi+maths+science desc) as rnk
from t
) t
where rnk = 1
id | total_score |
---|---|
1 | 325 |
select
max(english+hindi+maths+science) as total_score
from t
total_score |
---|
325 |