Public
Edited
Dec 27, 2023
15 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
select 2.0 /5

Insert cell
Insert cell
chinook.db
select *
from InvoICes;
Insert cell
Insert cell
chinook.db
SELECT InvoiceDate AS Date
From Invoices;
Insert cell
Insert cell
chinook.db
SELECT DISTINCT BillingCountry AS Country
FROM Invoices;
Insert cell
Insert cell
Insert cell
chinook.db
SELECT CustomerId AS ID, FirstName, Country
FROM customers;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
SELECT
InvoiceDate,
BillingCountry,
BillingCity,
Total
FROM invoices
WHERE BillingCountry <> 'Germany';
Insert cell
Insert cell
Insert cell
chinook.db
SELECT
InvoiceDate,
BillingCountry,
BillingCity,
Total
FROM invoices
WHERE BillingCountry = 'Germany' AND BillingCity <> 'Berlin';
Insert cell
Insert cell
Insert cell
chinook.db
SELECT date(InvoiceDate) AS Date, CustomerId, Total
From Invoices
WHERE date(InvoiceDate) between '2010' AND '2012';
Insert cell
Insert cell
Insert cell
chinook.db
-- cocantenate FirstName || LastName AS Name
Select
FirstName || ' ' || LastName AS Name,
Title
FROM employees
WHERE Title IN ('General Manager', 'Sales Manager', 'IT Manager');
-- WHERE ('General Manager', 'Sales Manager', 'IT Manager') IN Title;
-- WHERE Title = 'General Manager' OR Title = 'IT Manager' OR Title = 'Sales Manager';

Insert cell
Insert cell
Insert cell
chinook.db
SELECT InvoiceId, InvoiceDate, BillingCountry, Total
FROM Invoices
WHERE BillingCountry IN ('USA', 'Canada') AND Total > 8;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
SELECT title, count(*)
from employees
GROUP BY(title);
Insert cell
Insert cell
Insert cell
chinook.db
SELECT
strftime('%Y', InvoiceDate) AS Year,
SUM(Total) AS Total
from invoices
GROUP BY Year
ORDER BY Total DESC
LIMIT 3;
Insert cell
Insert cell
chinook.db
SELECT name
FROM Artists
Order By name DESC
LIMIT 4;
Insert cell
Insert cell
Insert cell
chinook.db
SELECT Composer, Count(*) as TrackAmmount
FROM Tracks
WHERE Composer is not null
GROUP BY Composer
ORDER BY TrackAmmount Desc
Limit 10;

Insert cell
Insert cell
Insert cell
chinook.db
SELECT Composer, MAX(Milliseconds) as Milliseconds
FROM Tracks
Where Composer is not null
Group By Composer
Order By Milliseconds DESC
Limit 10;

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
select
c.FirstName || ' ' || c.LastName as name,
sum(i.Total) as total_spent,
count(i.InvoiceDate) as n_times_shopped
from customers c
join invoices i on c.CustomerId = i.CustomerId
group by name
order by total_spent desc;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
select
t.Composer as artist,
count(ii.InvoiceId) as n_tracks_bought
from tracks t
left join invoice_items ii on t.TrackId = ii.TrackId
where t.composer is not null
group by artist
order by n_tracks_bought asc;
Insert cell
Insert cell
Insert cell
chinook.db
--your code goes here

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
select
a.Name as Artist,
t.Composer,
t.Name as Track
from artists a
full outer join tracks t
on a.Name = t.Composer;
Insert cell
Insert cell
chinook.db
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
chinook.db
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
chinook.db
select c
from
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