SQL Queries Practice & Solutions

Solve following queries using aggregate functions for the table.

Table: sales (orderID OrderDate OrderPrice OrderQuantity CustomerName)

0

1.Count how many orders have made a customer with customer name of Smith.

1

2.Find the number of unique customers that have ordered from the store.

2

3.Find out total no. of items ordered by all the customers.

3

4.Find out the average number of items per order.

4

5.Find out the average order quantity for all orders with order price greater than 200.

5

6.Find out what was the minimum price paid for any of the orders.

6

7.Find out the highest order price from the given sales table.

7

8.List out unique customers name only from the table.

8

9.List out the name of the customers who have given an order in the month of DECEMBER.

9

10.Find out the total amount of money spent for each of the customers.

10

11. Select all unique customers, who have spent more than 1200 in the store.

11


Now I had updated my table and inserted more values in it.

Capture


12.Select all the customers that have ordered more than 5 items in total from all their orders.

12

13.Select all customers who have spent more than 1000, after 10/01/2005.

13

14.Select orders in increasing order of order price.

14

15 Select orders in decreasing order of order price.

15


Thank You, Like, Share, Subscribe.

Advertisements

SQL Commands: Basics Of SQL

SQL Stands For Structure Query Language.

SQL Is An Important Part Of Database Management System, Which Manages Data In Database With Respective Commands And Helps To Retrieve And Manage It Whenever It Is Required.

Following Link Contains Basic Commands Of SQL.

Watch Here.