-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBase.sql
More file actions
75 lines (33 loc) · 1.57 KB
/
Copy pathBase.sql
File metadata and controls
75 lines (33 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- Retrieving data FROM statement
-- Select using column names SELECT statement
-- Select using column names and ALIAS
-- Select WHERE clause
-- Select statement and wildcard "*"
-- % Wildcard
-- Starts with
-- Ends with
-- In between
/****Aggregate functions***/
--COunt elements on table
--Average values from a column
--Order elements based on an attribute ORDER BY statement
/*Hands-on
* Find out how many people take longer than 20 mins on average to get to work (hint: query the state_workforce table)
* Sort the results to find out what states have the longest average time to get to work
* Modify your query to show only the records of New York, New Jersey, New Hampshire and New Mexico
*/
--Inner/regular join
--From state crime subquery to sub-select states from state computer data where households with computer higher or equal to 93
/*Hands-ON
Find the maximum percentage of the people with education of high school or higher
from states where the rate of property theft is above 2,500
*/
/*Hands-ON
1. Create an inner join using aliases with tables state_crime and state_people. Make sure to observe attributes from:
State
Rates of Property theft
Crime Year
Employment_Firms_Total*/
/*2. Add a new row to state people for state ‘US’ with totals of employment firms and averages of age percentages*/
/*3. Add a new ‘division’ row as a division of 100 * rates of property theft by employment firms total */
/*4. Create other types of joins and see the differences*/