BLACK FRIDAY EXTRA SAVINGS EVENT - EXTENDED
START FREE

Help with the WHEN/WHERE clause

Hey all!

Im working through the Guided Project: Answering Business Questions using SQL and I would like to go back and study a bit more before attempting again. I had a glance at the solution and the part/logic I was missing was from:

WITH country_or_other AS
(
SELECT
CASE
WHEN (
** SELECT count()**
** FROM customer**
** where country = c.country**
) = 1 THEN “Other”
ELSE c.country
END AS country,
c.customer_id,
il.

FROM invoice_line il
INNER JOIN invoice i ON i.invoice_id = il.invoice_id
INNER JOIN customer c ON c.customer_id = i.customer_id
)

Specifically the WHEN/WHERE clause.

Could someone point me in the right direction to better learn this or explain what the code is doing in plain English.

where country = c.country**
) = 1 THEN “Other”

Is my main issue.

Thanks heaps!

Correlated Subquery: CASE and Subqueries

Thank you! really Nice wiki article and thread. Helped heaps!!