Public
Edited
Jun 7, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pizzeriaDB
SELECT row_number() over (partition by Category order by Launch) as "Row Number", *
FROM products
Insert cell
Insert cell
pizzeriaDB
SELECT products.name
, products.size
, products.category
, count(distinct orders.id) as "Number of Orders"
, rank() over (partition by products.category order by count(distinct orders.id) DESC) as "Order Rank"
FROM products
JOIN order_items
ON products.SKU = order_items.SKU
JOIN orders
ON order_items.orderId = orders.id
GROUP BY 1, 2, 3
Insert cell
Insert cell
pizzeriaDB
SELECT products.name
, products.size
, products.category
, date_part('year', orders.orderDate::date)::string as year_name
, row_number() over (partition by year_name order by orderDate asc) as row_num
FROM products
JOIN order_items
ON products.SKU = order_items.SKU
JOIN orders
ON order_items.orderId = orders.id
ORDER BY row_num, year_name
LIMIT 3
Insert cell
Insert cell
pizzeriaDB
WITH utahStores AS (
SELECT *
FROM stores
WHERE state = 'Utah'
)

SELECT date_trunc('month', orders.orderDate::date) as "Month Name"
, count(distinct orders.id) as "Number of Orders"
FROM orders
JOIN utahStores
ON orders.storeId = utahStores.id
GROUP BY 1
Insert cell
Insert cell
pizzeriaDB
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
pizzeriaDB
WITH newData AS (
SELECT orders.id
, products.*
FROM orders
LEFT
JOIN order_items
ON orders.id = order_items.orderId
LEFT
JOIN products
ON order_items.SKU = products.SKU
)

SELECT DISTINCT name
, Size
, count(distinct id)
FROM newData
WHERE Category = 'Vegetarian'
GROUP BY 1, 2
Insert cell
pizzeriaDB
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
groceries
SELECT avg(amount) as avg_amount
FROM groceries
WHERE category = 'Fruits'
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more