UDEMY - The Ultimate MySQL Bootca…The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert를 수강하며 정리한 글
문제는 129강에 있음
-- 1번 제목에 stories가 들어간 책
SELECT title
FROM books
WHERE title LIKE '%stories%';
-- 2 page가 가장 긴 책의 이름과 페이지
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
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 lower 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 Sort Alphabetically BY Last Name and print like this 'MY FAVORITE AUTHOR IS RAYMOND CARVER!'
SELECT
UPPER(
CONCAT('my favorite author is ',author_fname,' ', author_lname,'!')
) AS 'yell'
FROM books
ORDER BY author_lname;