SQL - Assignment Part 1
SQL Assignment Part 1
Let's consider two
tables: "Customers" and "Orders".
CustomerID | CustomerName |
City ----------------------------------- 1 | John Doe | New York 2 | Jane Smith | Los Angeles 3 | David Johnson | Chicago |
OrderID | CustomerID | OrderDate ------------------------------- 1 | 1 | 2023-05-01 2 | 2 | 2023-05-02 3 | 1 | 2023-05-03 4 | 3 | 2023-05-04 5 | 2 | 2023-05-05 |
Now,
- Retrieve all orders with customer
information (CustomerID, CustomerName, City).
- Retrieve all customers who have placed
an order.
- Retrieve the total number of orders
for each customer.
- Retrieve the customer(s) who placed
the earliest order.
- Retrieve the customer(s) who placed
the latest order.
- Retrieve the order(s) with the highest
order ID.
- Retrieve the customer(s) who have
never placed an order.
- Retrieve the customer(s) who have
placed more than two orders.
- Retrieve the order(s) placed on a
specific date.
- Retrieve the customer(s) who have
placed orders in both New York and Los Angeles.
- Retrieve the customer(s) who have
placed orders in at least three different cities.
- Retrieve the customer(s) who have
placed orders in all cities.
- Retrieve the customer(s) who have
placed orders in the same city more than once.
- Retrieve the customer(s) who have
placed orders on consecutive days.
- Retrieve the order(s) placed by
customers whose names contain the word "Smith".
- Retrieve the order(s) placed by
customers whose names start with the letter "J".
- Retrieve the order(s) placed by
customers whose names end with the letter "n".
- Retrieve the customer(s) who have
placed orders after a specific date.
- Retrieve the customer(s) who have
placed orders before a specific date.
- Retrieve the customer(s) who have
placed orders between two specific dates.
- Retrieve the customer(s) who have
placed an order and their order count.
- Retrieve the customer(s) who have
placed an order and the total amount spent on orders.
- Retrieve the customer(s) with their
latest order information (OrderID, OrderDate).
- Retrieve the customer(s) with the
average order count.
- Retrieve the customer(s) with the
maximum and minimum order dates.
- Retrieve the customer(s) who have
placed an order in every month of a given year.
- Retrieve the customer(s) who have
placed orders in more than three different months.
- Retrieve the customer(s) who have
placed orders on weekdays (Monday to Friday).
- Retrieve the customer(s) who have
placed an order with the highest total order amount.
- Retrieve the customer(s) who have
placed an order with the lowest total order amount.
- Retrieve the customer(s) who have
placed an order with a total order amount above the average.
- Retrieve the customer(s) who have
placed an order with a total order amount below the average.
- Retrieve the customer(s) who have
placed an order immediately after another order.
- Retrieve the customer(s) who have
placed an order immediately before another order.
- Retrieve the customer(s) who have
placed orders in all consecutive months.
- Retrieve the customer(s) who have
placed an order on the same date as another customer.
- Retrieve the customer(s) who have
placed an order on a date that no other customer has.
- Retrieve the customer(s) who have
placed an order on a date that all other customers have placed an order.
- Retrieve the customer(s) who have
placed an order with the highest number of items.
- Retrieve the customer(s) who have
placed an order with the lowest number of items.
- Retrieve the customer(s) who have
placed an order with at least one item that costs more than a specific
amount.
- Retrieve the customer(s) who have
placed an order with all items costing less than a specific amount.
- Retrieve the customer(s) who have
placed an order containing items from at least three different categories.
- Retrieve the customer(s) who have
placed an order containing items from all available categories.
- Retrieve the customer(s) who have
placed an order where the total order amount is equal to the sum of the
individual item prices.
- Retrieve the customer(s) who have
placed an order with the highest average item price.
- Retrieve the customer(s) who have
placed an order with the lowest average item price.
- Retrieve the customer(s) who have
placed an order with the highest number of distinct items.
- Retrieve the customer(s) who have
placed an order with the lowest number of distinct items.
- Retrieve the customer(s) who have
placed an order with the longest time interval between two consecutive
orders
Comments
Post a Comment