Marketing Campaign Duration
Easy
You are given 3 tables, campaign, user and transaction with the following columns
campaign table:
user table:
transaction table
Write a SQL query that calculates the average duration of campaigns.
SQL-- SQLite (which is what the editor is using)
SELECT AVG(julianday(date_end) - julianday(date_start)) AS average_duration
FROM campaign;
-- MySQL
SELECT AVG(DATEDIFF(date_end, date_start)) AS avg_campaign_length
FROM campaign;
-- Postgresql
SELECT AVG(date_end - date_start) AS avg_campaign_length
FROM campaign;
SELECT AVG(julianday(date_end) - julianday(date_start)) AS avg_campaign_duration FROM campaign;