Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Premium by Line of Business
00:00
5 left

Premium by Line of Business

EasySQL · PostgreSQL

Problem

Write a SQL query to find the total premium written by line of business for the current fiscal year at AXA XL.

Use the provided premium transaction, line of business, and fiscal year data. Include written transactions for the fiscal year marked as current, and exclude transactions that are not written or lack a line of business.

Output

  1. One row per included line of business.
  2. Columns: line_of_business and total_premium_written.
  3. Sort by total premium descending, with line of business ascending as the tie-breaker.

Schema

premium_transactions
ColumnTypeDescription
premium_transaction_idPKINTUnique premium transaction identifier
line_of_business_idINTReference to the line of business
fiscal_year_idINTReference to the fiscal year
premium_amountNUMERIC(14,2)Premium amount for the transaction
transaction_statusVARCHAR(20)Transaction status
lines_of_business
ColumnTypeDescription
line_of_business_idPKINTUnique line-of-business identifier
line_of_business_nameVARCHAR(80)AXA XL line-of-business name
fiscal_years
ColumnTypeDescription
fiscal_year_idPKINTUnique fiscal year identifier
fiscal_yearINTFiscal year number
fiscal_year_labelVARCHAR(20)Display label for the fiscal year
is_currentBOOLEANWhether this is the current fiscal year
Tablespremium_transactionslines_of_businessfiscal_years
Interviewer

Your question is Premium by Line of Business. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

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.