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
B
B is not correct because there is no subquery. Correct is probably A. The answers are not complete, though.
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;
Probably is A