Kata SQL

SQL Basics: Simple WITH

departments table schema

  • id
  • name

sales table schema

  • id
  • department_id (department foreign key)
  • name
  • price
  • card_name
  • card_number
  • transaction_date

resultant table schema

  • id
  • name
WITH special_sales AS
(SELECT * FROM sales
WHERE price > 90.00)
SELECT id, name FROM departments
WHERE id
IN (SELECT department_id
FROM sales
WHERE price > 90.00)

--

--

My homepage to record my thought processes for solving SQL and Algorithm questions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store