MySQL Question List the title name type and pages of the lon

MySQL Question

List the title name, type and pages of the longest book (count in pages) without using max().

(Hint: use a subquery and ALL)

I had this but it displays nothing

SELECT title_name, type, pages
FROM titles
WHERE pages >= ALL(
SELECT pages
    FROM titles
);

Solution

SELECT title_name, type, pages
FROM titles
WHERE pages > ALL(
SELECT t1.pages
    FROM titles t1,titles t2 where t1.pages<t2.pages);

The Nested Query will return all values ecxept the maximum value

Then since ALL was given in the main query and only > Symbol this will be true

MySQL Question List the title name, type and pages of the longest book (count in pages) without using max(). (Hint: use a subquery and ALL) I had this but it di

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site