BLACK FRIDAY EXTRA SAVINGS EVENT - EXTENDED
START FREE

3. Question 3 Scalar Subqueries Assessment

My Code: < SELECT first_name || ’ ’ || last_name AS name, (SELECT SUM(total)
FROM invoice
WHERE customer_id = 18) AS total
FROM customer
WHERE customer_id = 18;>

Replace this line with your code
Write a query to calculate the name column by concatenating the first_name and last_name of the customer with customer_id = 18.

Use the query written in the previous step as a subquery to write a query that computes the above table. The total columns should be the overall purchase amount from the invoice table where customer_id = 18.

-Result so not correct-

The subquery should apply to the customer table and concatenate first_name last_name for customer_id=18. Not the SUM(total).

Do you mind providing the code

I attached my code below, but I keep getting an error

SELECT (SELECT first_name || ’ ’ || last_name
FROM customer
WHERE customer_id = 18) AS name,
SUM(total) AS purchase_amount
FROM invoice;