Database Changes SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL live · 3 guided

Publish an Active-Account View

Create active_account_summary exposing account_id, account_name, tier, and credit_limit for active accounts.

  • Views
  • Filtering

Exercise brief

Understand the request

Customer success Downstream users need a named query contract without inactive or trial accounts.

Customer success needs a stable, reusable interface containing only active account profiles.

Return

  • Publish the exact four-column view contract.

Constraints

  • Filter status to active.
  • Do not expose status itself.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

accounts

  • account_idINTEGER
  • account_nameVARCHAR(100)
  • tierVARCHAR(20)
  • statusVARCHAR(20)
  • credit_limitINTEGER

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

A view stores a named SELECT definition, not a copied result set.

Hint 2

Write CREATE VIEW ... AS followed by the four-column SELECT and active filter.

Hint 3

CREATE VIEW active_account_summary AS SELECT ... FROM accounts WHERE status = 'active';

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
CREATE VIEW active_account_summary AS
SELECT account_id, account_name, tier, credit_limit
FROM accounts
WHERE status = 'active';

Why this works

The view provides a reusable interface while centralizing row filtering and column projection in the database.

Success check

The view returns only Acme Enterprise and Northstar Growth with the requested columns.

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.