GithubHelp home page GithubHelp logo

sql-study's Introduction

SQL Exercises

Database Schema

Database Schema

Beginner Level

Retrieving Data

  1. Retrieve all users from the Users table.
  2. Display the first and last names of all customers.
  3. Show the product names and quantities in stock from the Inventory table.
  4. List the invoice IDs, invoice dates, and total amounts from the Invoices table.
  5. Retrieve the usernames and email addresses of users with the 'admin' role.

Filtering and Sorting

  1. Display the products with a quantity in stock greater than 10.
  2. Show invoices where the total amount is greater than $1000.
  3. List customers whose last name is 'Smith'.
  4. Display the inventory items in alphabetical order based on product name.
  5. Retrieve users with the role 'employee' and order them by username.

Aggregation

  1. Calculate the total quantity of products in stock.
  2. Find the average unit price of products in the Inventory table.
  3. Count the number of invoices.
  4. Determine the maximum total amount among all invoices.
  5. Show the number of users for each role.

Intermediate Level

Joins

  1. Retrieve invoice details along with customer names for each invoice.
  2. List all payments with the corresponding invoice details (invoice ID, customer name, and payment amount).
  3. Display the product names and quantities in stock for each invoice.
  4. List all customers who have made payments, along with the total amount they paid.
  5. Retrieve all users along with their roles.

Subqueries

  1. Find customers who made payments exceeding $500.
  2. Show invoices where the total amount is equal to the maximum total amount.
  3. List users who do not have a specified role.
  4. Display products that have not been included in any invoices.
  5. Find customers who haven't made any payments.

Advanced Level

Window Functions

  1. Rank customers based on the total amount they spent on invoices.
  2. Calculate the running total of payments for each customer.
  3. Determine the average quantity in stock for each product over time.
  4. Rank products based on the total quantity sold.
  5. Identify the top-paying customer for each invoice.

Advanced Joins

  1. Retrieve all invoices along with the corresponding products even if there are no associated invoice items.
  2. List customers who have not made any payments, including their last invoice date.
  3. Show users and their roles, even if they don't have a role specified.
  4. Display the total amount of payments for each customer, including customers with no payments.
  5. List all products along with the total quantity sold.

Advanced Aggregation

  1. Calculate the median unit price for products in the Inventory table.
  2. Find the customers with the highest total amount spent on invoices.
  3. Determine the month with the highest total sales (sum of invoice amounts).
  4. Identify the product with the highest total revenue.
  5. Calculate the percentage of total revenue contributed by each product.

sql-study's People

Contributors

deivycode avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.