SQL · Instacart · Medium
A marketing dataset stores advertiser spending in wide format, with separate columns for programs A, B, and C. A second table contains program-level revenue and cost. Write an ANSI SQL query that first reshapes the spending data into long format, then computes two result sets. Map the spending columns as follows: spend_prog_A to 'A', spend_prog_B to 'B', and spend_prog_C to 'C'. Requirements Unpivot advertiser_spend into an intermediate long table with columns advertiser_id,…
Checking your access…