I’d like to write the code in bits but I can’t check in bits. How do I run code to check without completing entire code?
For example, this code won’t run without WHOLE CODE. THX
WITH
customer_country_purchases AS
(
SELECT
i.customer_id,
c.country,
SUM(i.total) total_purchases
FROM invoice i
INNER JOIN customer c ON i.customer_id = c.customer_id
GROUP BY 1, 2
),
What exactly do you wish to check in bits?
Because you can write the code in bits and check the bits. For example,
- you could first have just the
SELECT
to check out the columns from invoice
.
- you can then
JOIN
the two tables together and SELECT
columns from both.
- then you can use
SUM
before using GROUP BY
. And so on…
But, of course, those bits won’t represent the actual output because you will get the actual/intended outcome only when the entire logic of the code has been written out. It is about logically structuring/designing the solution, so you can split it out into individual steps. And those steps build on top of each other to get the desired outcome.