-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrendsInStartups.sql
94 lines (60 loc) · 2.34 KB
/
TrendsInStartups.sql
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
Howdy! It’s your first day as a TechCrunch reporter. Your first task is to write an article on the rising trends in the startup world.
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.
*/
-- Calculate the total number of companies in the table.
SELECT SUM(employees)
FROM startups;
-- We want to know the total value of all companies in this table.
SELECT SUM(valuation)
FROM startups;
-- What is the highest amount raised by a startup?
SELECT MAX(raised)
FROM startups;
-- Edit the query so that it returns the maximum amount of money raised, during ‘Seed’ stage.
SELECT MAX(raised)
FROM startups
WHERE stage = 'Seed';
-- In what year was the oldest company on the list founded?
SELECT MIN(founded)
FROM startups;
-- Return the average valuation.
SELECT AVG(valuation)
FROM startups;
-- Return the average valuation.
SELECT AVG(valuation)
FROM startups;
-- Return the average valuation, in each category.
SELECT category, AVG(valuation)
FROM startups
GROUP BY category;
-- Return the average valuation, in each category. Round the averages to two decimal places.
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***.
SELECT category,
ROUND(AVG(valuation), 2)
FROM startups
GROUP BY 1
ORDER BY 3 DESC;
-- First, return the name of each category with the total number of companies that belong to it.
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?
SELECT category, COUNT(*)
FROM startups
GROUP BY CATEGORY
HAVING COUNT(*) > 3;
-- What is the average size of a startup in each location?
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?
SELECT location, AVG(employees)
FROM startups
GROUP BY location
HAVING AVG(employees) > 500;