Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Users With No Orders

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Users With No Orders. Start with the requirements and the two tables on the right.

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.

Problem

Grammarly's commerce team wants to identify users who have never placed an order. Write a PostgreSQL query that finds these users from the users and orders tables.

Requirements

  1. Return each qualifying user's user_id and full_name.
  2. Include users with no matching order, including users who have never purchased Grammarly Pro or another paid product.
  3. Exclude users who have at least one order, and do not let orphaned or incomplete order records create false matches.
  4. Sort the results alphabetically by full_name, then by user_id.

Schema

users
ColumnTypeDescription
user_idPKINTEGERUnique Grammarly user identifier
full_nameVARCHAR(100)User's display name
emailVARCHAR(255)User's email address
orders
ColumnTypeDescription
order_idPKINTEGERUnique order identifier
user_idINTEGERUser associated with the order
product_nameVARCHAR(100)Purchased Grammarly product
order_statusVARCHAR(20)Order processing status
Tablesusersorders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results