Public
Edited
Apr 24
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
select Name
from tracks;
Insert cell
Insert cell
chinook.db
Type SQL, then Shift-Enter. Ctrl-space for more options.

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

Insert cell
Insert cell
Insert cell
chinook.db
select customerid as id, firstname, country as countryName from customers;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
-- Place a semi colon after invoice to see what in in it before making a choice for where and use or to choose muptiple options and is true or it just one has to be true

select *
from invoices
where billingcountry = "Germany" or billingcountry = "France";
Insert cell
Insert cell
Insert cell
chinook.db
-- <> means not equal

select *
from invoices
where billingcountry = "Germany" and billingcity <> "Berlin";
Insert cell
Insert cell
Insert cell
chinook.db
--Here the word and specifies start AND end of the range Create a new cell by click the plus sign to the bottom left and select a data source which is SQL Query and then chinook

select InvoiceDate as Date, CustomerId, Total
from invoices
where Date between '2010-01-01' AND '2012-01-01';
Insert cell
chinook.db
select name, milliseconds
from tracks
where milliseconds between 250000 and 300000 or milliseconds between 350000 and 4000000;
Insert cell
Insert cell
Insert cell
chinook.db
--

select FirstName, LastName, Title
from employees
where Title in ('General Manager', 'Sales Manager', 'IT Manager');
Insert cell
chinook.db
-- parenthese groups together all the values we are checking for example Germany France and USA

select billingcountry, total
from invoices
where billingcountry in ("Germany", "France", "USA");
Insert cell
chinook.db
-- The where clause target specific strings,numbers and intergers

select name, unitprice
from tracks
where unitprice in (0.99);
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 title, count(title) as numEmployees
from employees
group by title

Insert cell
Insert cell
Insert cell
chinook.db
select billingcountry, sum(total)
from invoices
group by billingcountry;
Insert cell
Insert cell
chinook.db
select billingcountry, sum(total) as totalSales
from invoices
group by billingcountry
order by totalSales desc
Insert cell
chinook.db
-- you can use order buy in any query anything you want to sort text or numbers

select name
from artists
order by name asc

Insert cell
Insert cell
Insert cell
chinook.db
--your code goes here

Insert cell
Insert cell
Insert cell
chinook.db
--your code goes here

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
-- use dot for the Inner Join syntax to classify Joins Distinct is used to specify

select distinct artists.name, albums.title
from artists
inner join albums on artists.artistid = albums.artistid
order by artists.name, albums.title asc;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chinook.db
Type SQL, then Shift-Enter. Ctrl-space for more options.

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
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more