반응형
You work at a book store. It's the end of the month, and you need to find out the 5 bestselling books at your store. Use a select statement to list names, authors, and number of copies sold of the 5 books which were sold most.
books table schema
- name
- author
- copies_sold
Solution:
SELECT * FROM books ORDER BY copies_sold DESC LIMIT 5
Result:
name | author | copies_sold |
The Unbearable Lightness of Being | Milan Kundera | 9065 |
On the Genealogy of Morality | Friedrich Nietzsche | 8732 |
On Liberty | John Stuart Mill | 7365 |
On the Origin of Species | Charles Darwin | 3805 |
Studies on Hysteria | Sigmund Freud | 2765 |
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
SQL Basics: Up and Down (0) | 2022.06.21 |
---|---|
GROCERY STORE: Inventory (0) | 2022.06.20 |
SQL Basics: Simple table totaling. (0) | 2022.06.18 |
SQL Basics: Simple IN (0) | 2022.06.17 |
Easy SQL: Absolute Value and Log to Base (0) | 2022.06.16 |