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
Start free
SQL Filter, Order, Select
00:00
5 left

SQL Filter, Order, Select

EasySQL · PostgreSQL

Problem

Write a SQL query that returns specific columns from a table, filters the results based on multiple conditions, and orders them in descending order.

Use the shipments table. Return delivered shipments with a non-West destination and a freight charge greater than 500.

Output

  1. Return shipment_id, tracking_number, and freight_charge.
  2. Include only rows meeting all stated conditions.
  3. Order by freight_charge descending, with shipment_id ascending as the tie-breaker.

Schema

shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
tracking_numberVARCHAR(20)Shipment tracking reference
statusVARCHAR(30)Current shipment status
destination_regionVARCHAR(30)Shipment destination region
freight_chargeDECIMAL(10,2)Charge billed for transporting the shipment
Tablesshipments
Interviewer

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

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.