You are given campaign delivery and conversion data from Lucid Motors marketing efforts. Write a PostgreSQL query that returns one row per campaign for January 2024, showing the campaign name, channel, total spend, total leads, total test-drive bookings, and separate monthly session totals for the Lucid website and the Lucid app. Only include campaigns whose January spend is greater than 0 and whose total January leads are at least 20.
This tests the same thinking behind nested IF statements, INDEX-MATCH lookups, and pivot tables in Excel, but in SQL: conditional logic with CASE, joining lookup data, and reshaping metrics into columns.