Practice Free
← Syllabus|
Easy

16. Expiring SaaS Free Trials (7-Day Conversion Window)

EasyFundamentalsPostgreSQL 16PRO
Table: saas_trials
+-----------------------+--------------+
| Column Name           | Type         |
+-----------------------+--------------+
| account_id            | int          |
| org_name              | varchar(100) |
| days_until_expiration | int          |
| total_logins          | int          |
+-----------------------+--------------+

account_id is the unique key for this table. Each row contains record details for this enterprise dataset.

Product-led growth (PLG) sales teams reach out to high-engagement trial accounts whose 14-day trials expire within the next 7 calendar days to offer discounted annual contracts.

Write a query to retrieve all trial accounts in `saas_trials` where: - `days_until_expiration BETWEEN 1 AND 7` - `total_logins >= 5` Return: 1. `account_id` 2. `org_name` 3. `days_until_expiration` 4. `total_logins` Order results by `days_until_expiration` ascending, then by `total_logins` descending.

Return the result table ordered as specified. The result format is in the following example.

Example 1:
Input:
Preparing sample rows...
Output:
Calculating benchmark target...
Explanation:

High-engagement SaaS trials approaching expiration.

Constraints:
  • Query must utilize clause(s): WHEREORDER BY
  • Result order matters (tie-breakers and sort order must be strictly preserved).
  • Engine: PostgreSQL 16 standard syntax (in-browser WASM).
query.sql|PostgreSQL 16 WASM
Loading SQL editor...
You must run your code first

Write your SQL query in the editor and click Run or Submit to test against in-browser PostgreSQL 16 WASM.

About the “Expiring SaaS Free Trials (7-Day Conversion Window)” SQL Problem

Business Scenario

Product-led growth (PLG) sales teams reach out to high-engagement trial accounts whose 14-day trials expire within the next 7 calendar days to offer discounted annual contracts.

Expected Output & Criteria

High-engagement SaaS trials approaching expiration.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM
CREATE TABLE saas_trials (
        account_id INT PRIMARY KEY,
        org_name VARCHAR(100) NOT NULL,
        days_until_expiration INT NOT NULL,
        total_logins INT NOT NULL
      );

Target SQL Clauses & Operators

WHEREORDER BY

Want more Fundamentals practice?

Explore the full syllabus of 16 exercises and syntax guides.

View Fundamentals Track