The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
62 views

Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.

Write an SQL query to list the regno of examinees who have a score greater than the average score.

asked in Databases by Veteran (108k points) | 62 views

2 Answers

+1 vote
Best answer

There are many ways to write a query, all of which will perform the same task. One way is:

SELECT regno
FROM examinee
WHERE score > (SELECT AVG(score)
               FROM examinee )

Here, the inner query is returning the average of the scores. And outer query selects those regno that have a score greater than this average.

answered by Veteran (15.3k points)
selected by
0 votes
SELECT regno
FROM examinee
HAVING score > avg(score)

 

answered by (17 points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,687 questions
40,230 answers
114,266 comments
38,783 users