Skip to content

Instantly share code, notes, and snippets.

@200even
Created July 27, 2015 20:51
Show Gist options
  • Save 200even/8f10c48a32cf5b1fa608 to your computer and use it in GitHub Desktop.
Save 200even/8f10c48a32cf5b1fa608 to your computer and use it in GitHub Desktop.
Scott - Week5.Day1 SQL Basics
--Create a table for cities
create table cities
(Place varchar(30),
estimate2013 int,
census2010 int,
change decimal(9,4));
--Insert data for each row
insert into cities
(Place, estimate2013,census2010,change)
values('Houston','2195914','2100263',0.0455),
('San Antonio','1409019','1327407','0.0615'),
('Dallas','1257676','1197816','0.0500'),
('Austin','885400','790390','0.1202'),
('Fort Worth','792727','741206','0.0695');
--Find all records in the table
select * from cities;
--Find the city with the largest population change
select Place from cities
where change= (select MAX(change) from cities);
--Delete Dallas
Delete from cities
where Place = 'Dallas';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment