Applying SQL to Real-World Problems
Dmitriy (Dima) Gorenshteyn
Lead Data Scientist, Memorial Sloan Kettering Cancer Center
Columns in address
table
address_id
address
district
city
postal_code
phone
postal_code | distance |
---|---|
53182 | 3.4 |
15540 | 10.2 |
67912 | 1.9 |
81766 | 21 |
... | ... |
1) Create a new table
CREATE TABLE zip_distance (
postal_code INT,
distance FLOAT
);
2) Insert data into table
INSERT INTO zip_distance (postal_code, distance)
VALUES
(53182, 3.4),
(15540, 10.2),
(67912, 1.9);
SELECT film_id, title
FROM film
WHERE rating = 'G';
CREATE TABLE family_films AS
SELECT film_id, title
FROM film
WHERE rating = 'G';
CREATE VIEW family_films AS
SELECT film_id, title
FROM film
WHERE rating = 'G';
Applying SQL to Real-World Problems