Example 2 on Correlated Nested Queries in SQL

For Complete YouTube Video: Click Here

In this class, we will try to understand Example 1 on Correlated Nested Queries in SQL.

We have already discussed the concepts of Correlated Nested Queries in our previous classes.

Example 2 on Correlated Nested Queries in SQL

The query is as shown below.

The relation book (title, price) contains the titles and prices of different books. Assuming that no two books have the same price, what does the following SQL query list?

      select title from book as B where (select count(*) from book as T where T.price > B.price) < 5 

(A) Titles of the four most expensive books

(B) Title of the fifth most inexpensive book

(C) Title of the fifth most expensive book Titles of the five most expensive books

(D) Titles of the five most expensive books

A clear explanation of the query is made in the above youtube link.