Which statement correctly demonstrates using a subquery as a scalar expression?

Which statement correctly demonstrates using a subquery as a scalar expression?

Which statement correctly demonstrates using a subquery as a scalar expression?

A.
SELECT (
SELECT SUM (population)
FROM Country
SELECT SUM (population)
FROM Country
WHERE Code =’CAN’
)

B.
SELECT SUM (population)
FROM Country
WHERE Code =”USA”
+ (SELECT SUM (population)
FROM Country
WHERE Code =.’CAN’
)

C.
SELECT
(SELECT SUM (population)
FROM Country
WHERE Code =’USA’
FROM country
WHERE Code= ‘CAN’
)

D.
(SELECT SUM (population)
FROM Country
WHERE Code =”USA’

Explanation:
Reference:
http://dev.mysql.com/doc/refman/5.0/en/scalar-subqueries.html



Leave a Reply 4

Your email address will not be published. Required fields are marked *


swdx

swdx

B is not correct because there is no subquery. Correct is probably A. The answers are not complete, though.

Jay

Jay

Looks like A.

Here is an example out of a book on Scalar Expressions:

SELECT (SELECT SUM (Population) FROM City) / (SELECT SUM(POPULATION) FROM Country) AS ratio;