-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartups project SQL
More file actions
66 lines (47 loc) · 1.57 KB
/
Copy pathStartups project SQL
File metadata and controls
66 lines (47 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
To get you started with your research, your boss emailed you a project.sqlite file that contains a table called startups. It is a portfolio of some of the biggest names in the industry.
Write queries with aggregate functions to retrieve some interesting insights about these companies.
In what year was the oldest company on the list founded?
CODE:
SELECT MIN(founded)
FROM startups;
Return the average valuation.
CODE:
SELECT AVG(valuation)
FROM startups;
Return the average valuation, in each category.
Round the averages to two decimal places.
CODE:
SELECT category, ROUND(AVG(valuation), 2)
FROM startups
GROUP BY category;
Return the average valuation, in each category.
Round the averages to two decimal places.
Lastly, order the list from highest averages to lowest.
CODE:
SELECT category, ROUND(AVG(valuation), 2)
FROM startups
GROUP BY category
ORDER BY ROUND(AVG(valuation), 2) DESC;
First, return the name of each category with the total number of companies that belong to it.
CODE:
SELECT category, COUNT(*)
FROM startups
GROUP BY category;
Next, filter the result to only include categories that have more than three companies in them.
What are the most competitive markets?
CODE:
SELECT category, COUNT(*)
FROM startups
GROUP BY category
HAVING COUNT(*) > 3;
What is the average size of a startup in each location?
CODE:
SELECT location, AVG(employees)
FROM startups
GROUP BY location;
What is the average size of a startup in each location, with average sizes above 500?
CODE:
SELECT location, AVG(employees)
FROM startups
GROUP BY location
HAVING AVG(employees) > 500;