Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Querying 2025 Closed Won Account Revenue
00:00
5 left

Querying 2025 Closed Won Account Revenue

MediumSQL · PostgreSQL

Problem

Explain the order of execution in Tableau when building a view or dashboard.

For the SQL portion, use the supplied PostgreSQL tables to produce the requested result while explaining how the query stages correspond to Tableau's order of operations.

Output

  1. One row per qualifying account, with region, account_name, and total_revenue.
  2. Include only qualifying closed-won revenue from 2025 with a positive account total.
  3. Order by total_revenue descending, then region and account_name ascending.

Output details

  • Treat closed-won opportunities as rows where stage = 'Closed Won'.
  • Interpret revenue from 2025 as close_date >= DATE '2025-01-01' and close_date < DATE '2026-01-01'.

Schema

accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
account_nameVARCHAR(100)Account name
regionVARCHAR(50)Account sales region
opportunities
ColumnTypeDescription
opportunity_idPKINTUnique opportunity identifier
account_idINTRelated account identifier
stageVARCHAR(40)Opportunity sales stage
close_dateDATEOpportunity close date
amountDECIMAL(12,2)Opportunity revenue amount
Tablesaccountsopportunities
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.