llearn
Version:
Bad-ass developers create awesome apps
66 lines (61 loc) • 2.46 kB
Markdown
# Test SQL selections
## Setup
- Create the following table and add the fields:
+ run: 'll testIO_TableSelection_Data.sql'
## Selection tests
- Select all books who's title contains the word 'stories'
- Show the book with the most pages.
- Show summary (title - year) of the last 3 books that were released.
- Find all books who's last name contains a space. Only show title and author name,
- Find the 3 books that is the lowest in stock. Show title, released date and stock quantity.
- Show title and author last name sorted by author last name and then by title.
- Show author name and last name in upper case, seperated by space in one column with name 'yell'.
Each line shoud start with 'MY FAVORITE AUTHOR IS '.
- Select all books with page count between 100 and 200 pages.
- Show title, author_lname and TYPE => If title contains:
+ 'stories' -> 'Short stories'
+ 'Just Kids' or 'A Heartbreaking Work' -> 'Memoir'
+ else 'Novel'
- Make this happen:
+----------------+---------+
| author_lname | COUNT |
+----------------+---------+
| Carver | 2 books |
| Chabon | 1 book |
| DeLillo | 1 book |
| Eggers | 3 books |
| Foster Wallace | 2 books |
| Gaiman | 3 books |
| Harris | 2 books |
| Lahiri | 2 books |
| Saunders | 1 book |
| Smith | 1 book |
| Steinbeck | 1 book |
+----------------+---------+
## Groups test
- Find the number of book titles.
- Find the number of books that was released each year.
- Find the total number of books in stock.
- Find average release year for each author.
- Find the full name (name + surname in one column) of the author who wrote the longest book.
- Make this happen:
+------+------------+-----------+
| year | # of books | avg pages |
+------+------------+-----------+
| 1945 | 1 | 181.0000 |
| 1981 | 1 | 176.0000 |
| 1985 | 1 | 320.0000 |
| 1989 | 1 | 526.0000 |
| 1996 | 1 | 198.0000 |
| 2000 | 1 | 634.0000 |
| 2001 | 3 | 443.3333 |
| 2003 | 2 | 249.5000 |
| 2004 | 1 | 329.0000 |
| 2005 | 1 | 343.0000 |
| 2010 | 1 | 304.0000 |
| 2012 | 1 | 352.0000 |
| 2013 | 1 | 504.0000 |
| 2014 | 1 | 256.0000 |
| 2016 | 1 | 304.0000 |
| 2017 | 1 | 367.0000 |
+------+------------+-----------+