Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Select Distinct Values
00:00
5 left

SQL Select Distinct Values

EasySQL · PostgreSQL

Problem

How would you select distinct values from a column in SQL?

Use the wix_site_templates table and its template_category column. Return every unique category, including one row for NULL when present.

Output

  1. One column named distinct_template_category
  2. One row per distinct category value
  3. Sort alphabetically, with NULL last

Schema

wix_site_templates
ColumnTypeDescription
template_idPKINTUnique identifier for the site template
template_categoryVARCHAR(50)Category assigned to the site template
Tableswix_site_templates
Interviewer

Your question is SQL Select Distinct Values. Start with the requirements and the one table 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.