Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created June 16, 2014 15:20
Show Gist options
  • Save chriszf/7d35ec95f05845705858 to your computer and use it in GitHub Desktop.
Save chriszf/7d35ec95f05845705858 to your computer and use it in GitHub Desktop.
SQL> problem
Problem 2
Select statements can have an additional clause called the 'where' clause.
This lets us extract specific rows out of our table. Our where clause can be
specific enough to match a single row, or general enough to match a set of
rows. The format of a select statement with a 'where' clause is:
SELECT <column list> FROM <table name> WHERE <equality expression>;
Examples: http://sqlzoo.net/wiki/SELECT_basics -- 1
Task: Write a query that shows all the information about all salespeople from
the 'Northwest' region.
SQL> tables
The following tables are available:
salespeople
melons
customers
orders
order_items
SQL> select * from salespeople where region='Northwest';
3|linda@livefish.edu|d01ca6cd370257707a7afa49ef52f675|Ruth|Martinez|3-(728)674-6854|Northwest
10|heather@camido.name|98b3f63b7bc2b5c585ddf4e2f9b1e475|Norma|Fields|0-(993)752-9839|Northwest
12|kathy@yodoo.mil|f96b5c86f788918f323ad7fdf6a27de2|Michelle|Hart|9-(953)941-3544|Northwest
27|marilyn@zoovu.gov|6485f96897d0701891b0b7a03c7331a4|Anne|Butler|2-(133)167-7289|Northwest
30|marilyn@topicstorm.name|fa6f63099bc11d134c8fe126b118aff1|Lori|Nichols|5-(977)518-3111|Northwest
37|frances@rhynyx.mil|ed78e1f3346087bd1d87cdc83ac056b9|Susan|Hansen|5-(738)646-3905|Northwest
39|denise@zoomcast.org|2917cc869d03f05745daa9c49c2cf5e4|Jennifer|Cole|4-(759)826-3510|Northwest
40|helen@topiclounge.info|3dbc8c087fb4198b06aa6ecba1d3144d|Carol|Berry|8-(203)939-2699|Northwest
42|norma@babbleset.net|d4b650d39bebd6fb2d7ebf6b5d41ac6b|Louise|Gutierrez|8-(543)967-6844|Northwest
45|amy@blogtags.biz|40556c73d60c966d70f915c4ef16a62a|Heather|Dixon|9-(620)908-0206|Northwest
56|catherine@livefish.name|7415bb1f3480ee6ddbf472a415b5f29c|Amanda|Frazier|4-(286)086-8479|Northwest
58|jane@photobug.com|2917cc869d03f05745daa9c49c2cf5e4|Julia|Miller|4-(741)553-5443|Northwest
63|louise@skimia.biz|8c715b75267ca1e7e37c9b7f49e1b6f9|Annie|Hill|2-(829)398-0500|Northwest
70|brenda@quamba.net|09ad48cd817c28c7bfaa3fe82a992b1f|Phyllis|Wells|0-(393)971-5203|Northwest
72|teresa@photofeed.name|80523252251feda18d5af8ac188338ad|Lillian|Welch|7-(761)056-1705|Northwest
77|teresa@mycat.name|5d92224a4b9e9efee31a783e9603b1e1|Beverly|King|4-(374)915-9695|Northwest
87|diane@fivechat.biz|8a82cba171629aa2f806eb47a110db02|Stephanie|Jackson|5-(698)630-9917|Northwest
88|nancy@innoz.biz|296ff6f02974c0417ce77da60ef70f0a|Judy|Phillips|1-(633)277-7867|Northwest
96|marilyn@riffpedia.biz|e20552c05019492def57db0756abe4da|Deborah|Ross|8-(820)834-7329|Northwest
97|diane@wikivu.net|38702c09b6568ded3a3974590661c19e|Phyllis|Baker|3-(079)948-0868|Northwest
Correct!
select * from salespeople where region='Northwest';
Moving on...
[ Press Enter to continue ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment