All MicroEvals
You are working with a PostgreSQL database used by a softwar...
Create MicroEval
Header image for You are working with a PostgreSQL database used by a softwar...

You are working with a PostgreSQL database used by a softwar...

Prompt

You are working with a PostgreSQL database used by a software deployment platform. Given the schema below, write one SQL query that produces the requested report. Schema CREATE TABLE projects ( id BIGSERIAL PRIMARY KEY, name TEXT NOT NULL, organization_id BIGINT NOT NULL, created_at TIMESTAMPTZ NOT NULL ); CREATE TABLE deployments ( id BIGSERIAL PRIMARY KEY, project_id BIGINT NOT NULL REFERENCES projects(id), environment TEXT NOT NULL, status TEXT NOT NULL, started_at TIMESTAMPTZ NOT NULL, completed_at TIMESTAMPTZ, commit_sha TEXT NOT NULL ); CREATE TABLE deployment_events ( id BIGSERIAL PRIMARY KEY, deployment_id BIGINT NOT NULL REFERENCES deployments(id), event_type TEXT NOT NULL, created_at TIMESTAMPTZ NOT NULL ); CREATE TABLE incidents ( id BIGSERIAL PRIMARY KEY, project_id BIGINT NOT NULL REFERENCES projects(id), deployment_id BIGINT REFERENCES deployments(id), severity TEXT NOT NULL, opened_at TIMESTAMPTZ NOT NULL, resolved_at TIMESTAMPTZ ); Assume: deployments.status can be pending, running, succeeded, failed, or cancelled. deployments.environment can include development, staging, and production. incidents.severity can be low, medium, high, or critical. A deployment may have zero or more incidents associated with it. A project may have no production deployments during the reporting period. Task Write a PostgreSQL query that returns one row per project for every project that had at least one production deployment start during the last 30 days.