Introduction
A local bookstore is looking to improve their inventory management system. As their database administrator, you need to help them find specific books using MySQL queries. This challenge tests your ability to filter and sort data in a MySQL database.
Find Technical Books
The bookstore needs to identify all their technical books from the last two years (2022-2023), ordered from most expensive to least expensive. This information will help them make pricing decisions for their technical book section.
Tasks
- Connect to MySQL as the root user
- Use the
bookstoredatabase - Write a query that:
- Finds all technical books from 2022-2023
- Orders them by price in descending order
- Shows only the title, price, and publication year
- Save the results to a file named
technical_books.txtin the~/projectdirectory
Requirements
- All operations must be performed in the
~/projectdirectory - The query must use WHERE to filter by genre and publication year
- Results must be ordered by price in descending order
- Only books from years 2022 and 2023 should be included
- The output must include exactly the specified columns in the order: title, price, publication_year
- The output must be saved to a file named
technical_books.txtin the~/projectdirectory
Example
After writing the correct query, your results should look similar to this:
cat ~/project/technical_books.txt
+----------------------+-------+------------------+
| title | price | publication_year |
+----------------------+-------+------------------+
| Data Design Patterns | 39.99 | 2022 |
| SQL for Beginners | 34.99 | 2023 |
+----------------------+-------+------------------+
Summary
In this challenge, you practiced combining multiple SQL concepts: using WHERE clauses for filtering based on multiple conditions, and using ORDER BY for sorting results. These fundamental SQL skills are essential for performing data analysis and generating reports in real-world database applications. The ability to filter and sort data effectively allows you to extract precisely the information needed from large datasets.



