easy

Identify Active Premium Subscribers

You are working as a Data Analyst for a growing SaaS company. The marketing team wants to run a special promotional campaign exclusively for current premium members.

You are given a subscriptions table containing information about user subscription plans. Write a SQL query to identify all users who currently have an active 'Premium' subscription.

Your query should return the user_id, plan_type, and signup_date. The results must be ordered by the signup_date from newest to oldest.

Table Schema (subscriptions):

  • subscription_id (INTEGER): Unique identifier for the subscription.

  • user_id (INTEGER): Identifier for the user.

  • plan_type (VARCHAR): The type of plan (e.g., 'Basic', 'Pro', 'Premium').

  • status (VARCHAR): The current status of the subscription ('Active', 'Canceled', 'Paused').

  • signup_date (DATE): The date the subscription started.

1
2
3
4
5
Preparing...
Identify Active Premium Subscribers

You are working as a Data Analyst for a growing SaaS company. The marketing team wants to run a special promotional campaign exclusively for current premium members. You are given a subscriptions table containing information about user subscription plans. Write a SQL query to identify all users who currently have an active 'Premium' subscription. Your query should return the user_id , plan_type , and signup_date . The results must be ordered by the signup_date from newest to oldest. Table Schema ( subscriptions ): subscription_id (INTEGER): Unique identifier for the subscription. user_id (INTEGER): Identifier for the user. plan_type (VARCHAR): The type of plan (e.g., 'Basic', 'Pro', 'Premium'). status (VARCHAR): The current status of the subscription ('Active', 'Canceled', 'Paused'). signup_date (DATE): The date the subscription started.

Table Setup (SQL Schema)

-- DDL: Create tables
CREATE TABLE subscriptions (
    subscription_id SERIAL PRIMARY KEY,
    user_id INT NOT NULL,
    plan_type VARCHAR(50) NOT NULL,
    status VARCHAR(50) NOT NULL,
    signup_date DATE NOT NULL
);

-- DML: Insert sample data
INSERT INTO subscriptions (user_id, plan_type, status, signup_date) VALUES 
(101, 'Premium', 'Active', '2023-08-15'),
(102, 'Basic', 'Active', '2023-09-01'),
(103, 'Premium', 'Canceled', '2023-01-10'),
(104, 'Pro', 'Active', '2023-11-20'),
(105, 'Premium', 'Active', '2024-01-05'),
(106, 'Premium', 'Paused', '2023-06-18'),
(107, 'Premium', 'Active', '2022-12-01'),
(108, 'Basic', 'Canceled', '2023-03-14');
Home Videos Quiz Blog