- Understand how to use aggregation functions such as SUM(), AVG(), and MAX() in SQL queries.
- Learn to apply GROUP BY and ORDER BY clauses to structure and sort query results.
- Gain experience in applying conditional logic to aggregate and filter data efficiently.
- Practice using LIMIT to restrict the number of rows returned by a query.
π» A computer with internet access and a database setup (e.g., MySQL, PostgreSQL, etc.).
π A text editor (e.g., Visual Studio Code, Sublime Text, or any SQL editor).
π Intermediate knowledge of SQL queries, including aggregate functions and grouping.
π Write all your SQL queries in the answers.sql file.
βοΈ Answer each question concisely and make sure your queries are clear and correct.
π£οΈ Structure your responses clearly, and use comments if necessary to explain your approach.
Write an SQL query to show the total payment amount for each payment date from payments table.
- Display the payment date and the total amount paid on that date.
- Sort the results by payment date in descending order.
- Show only the top 5 latest payment dates.
Write an SQL query to find the average credit limit of each customer from customers table.
- Display the customer name, country, and the average credit limit.
- Group the results by customer name and country.
Write an SQL query to find the total price of products ordered from orderdetails table.
- Display the product code, quantity ordered, and the total price for each product.
- Group the results by product code and quantity ordered.
Write an SQL query to find the highest payment amount for each check number from payments table.
- Display the check number and the highest amount paid for that check number.
- Group the results by check number.
Good luck π