171k views
4 votes
Based on the contents of the BOOKS table, which line of the following SQL statement contains an error?1 SELECT isbn, title2 FROM books3 WHERE pubid =4 (SELECT pubid5 FROM books6 WHERE title = 'SHORTEST POEMS')7 AND retail-cost >8 (SELECT AVG(retail-cost)9 FROM books);A. Line 3B. Line 5C. Line 7D. none of the above

1 Answer

1 vote

Answer:

A. Line 3

Step-by-step explanation:

First, lets order the query like this:

1 SELECT isbn, title

2 FROM books

3 WHERE pubid =

4 (SELECT pubid

5 FROM books

6 WHERE title = 'SHORTEST POEMS')

7 AND retail-cost >

8 (SELECT AVG(retail-cost)

9 FROM books);

It's not necessary to filter through the pubid to find the books with the title "SHORTEST POEMS". The query could be just like this:

SELECT isbn, title

FROM books

WHERE title = 'SHORTEST POEMS'

AND retail-cost >

(SELECT AVG(retail-cost)

FROM books);

User Gasolin
by
5.5k points