Write a SQL query to calculate the click-through rate (CTR) of ads segmented by industry and company size over the last 30 days for LinkedIn marketing campaigns.
Use the provided LinkedIn Ads, LinkedIn Companies, and LinkedIn Ad Events tables. Include only segments with at least one impression during the period. CTR is clicks divided by impressions, expressed as a percentage.
Output
- One row per industry and company size segment.
- Columns:
industry, company_size, impressions, clicks, and ctr_percent.
- Include only events from the last 30 days through today and segments with impressions greater than zero.
- Order by
industry ascending with null industries last, then company_size ascending.