-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5_aggregrate.sql
64 lines (32 loc) · 1.48 KB
/
5_aggregrate.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
SELECT * FROM books;
SELECT COUNT(*) FROM books;
SELECT COUNT(author_fname) FROM books;
SELECT COUNT(DISTINCT author_fname) FROM books;
SELECT COUNT(DISTINCT author_lname) FROM books;
SELECT COUNT(DISTINCT author_fname,author_lname) FROM books;
SELECT COUNT(*) FROM books WHERE title LIKE '%the%';
SELECT title, author_lname FROM books;
SELECT author_fname,author_lname, COUNT(*) FROM books GROUP BY author_lname,author_fname;
SELECT released_year, COUNT(*) FROM books;
SELECT released_year, COUNT(*) FROM books GROUP BY released_year;
SELECT MIN(released_year)
FROM books;
SELECT MAX(pages) FROM books;
SELECT MIN(pages) FROM books;
SELECT MIN(author_fname) FROM books;
SELECT max(pages) FROM books;
SELECT * FROM books WHERE pages=634;
SELECT min(pages) FROM books;
SELECT Sum(pages) FROM books;
SELECT author_lname, author_fname, Sum(pages) FROM books GROUP BY author_lname,author_fname;
SELECT author_lname, author_fname, Sum(pages) FROM books GROUP BY author_lname,author_fname;
SELECT AVG(released_year) FROM books;
SELECT AVG(pages) FROM books;
SELECT released_year, AVG(stock_quantity) FROM books GROUP BY released_year;
SELECT author_fname,author_lname, AVG(pages) FROM books GROUP BY author_lname,author_fname;
-- assignment
SELECT COUNT(*) FROM books;
SELECT released_year,COUNT(*) FROM books GROUP BY released_year;
SELECT sum(stock_quantity) FROM books;
SELECT AVG(released_year) FROM books GROUP BY author_lname,author_fname;
SELECT MAX(pages) ,author_fname FROM books;