The relation rR M where R indicates roll number and M is the
The relation r(R, M), where R indicates roll number and M is the marks scored, is defined by the following table - create table if not exists r(R integer primary key, M integer not null); Using a scalar subquery, write an SQL query to find the R\'s and M\'s for all R\'s whose score was 15% or more above the average of the scores. The output should have 2 columns, R and M. List the results in order of scores, M, from highest to lowest.
Solution
Below is the SQL query.
Subquery is used for getting the average of the scores.
I am multiplying it by .15 so as to get the 15% of the average scores and then checking which students have marks greater or equal to this number
select R,M
From r
where M >= (Select 0.15*AVG(M) from r)
Order by M desc
