-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefined_strings.sql
More file actions
executable file
·109 lines (83 loc) · 2.69 KB
/
refined_strings.sql
File metadata and controls
executable file
·109 lines (83 loc) · 2.69 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Simplified Library Database
CREATE TABLE books
(
book_id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(100),
author_fname VARCHAR(100),
author_lname VARCHAR(100),
released_year INT,
stock_quantity INT,
pages INT,
PRIMARY KEY(book_id)
);
*/
-----------------------------------------------------------------------
/*
1.Select All Story Collections
Titles That contain 'stories'
*/
SELECT title FROM books WHERE title LIKE '%stories%';
-----------------------------------------------------------------------
-----------------------------------------------------------------------
/*
2.Find The Longest Book
Print Out the Title and Page Count
*/
SELECT title, pages FROM books ORDER BY pages DESC LIMIT 1;
-----------------------------------------------------------------------
-----------------------------------------------------------------------
/*
3.Print a summary containing the title and year, for the 3 most recent books
with the format "<Title> - <release_year>"
*/
SELECT
CONCAT (
title,
" - ",
released_year
) AS 'summary'
FROM books
ORDER BY released_year DESC LIMIT 3
;
-----------------------------------------------------------------------
-----------------------------------------------------------------------
/*
4.Find all books with an author_lname
that contains a space(" ")
*/
SELECT title,author_lname FROM books
WHERE author_lname LIKE "% %";
-----------------------------------------------------------------------
-----------------------------------------------------------------------
/*
5.Find The 3 Books With The Lowest Stock
Select title, year, and stock
*/
SELECT title, released_year, stock_quantity FROM books
ORDER BY stock_quantity LIMIT 3;
-----------------------------------------------------------------------
-----------------------------------------------------------------------
/*
6.Print title and author_lname, sorted first by author_lname and then by title
*/
SELECT title, author_lname FROM books
ORDER BY author_lname, title;
-----------------------------------------------------------------------
-----------------------------------------------------------------------
/*
7.Print your favorite books Sorted Alphabetically By Last Name of the author
with the format "MY FAVORITE AUTHOR IS <author_full_name> !"
*/
SELECT
UPPER(
CONCAT (
"My favorie author is ",
author_fname,
" ",
author_lname,
"!"
)
) AS 'yell' FROM books
ORDER BY author_lname;
-----------------------------------------------------------------------