0% found this document useful (0 votes)
4 views

MYSQL Assignment-3

The document contains SQL statements and their results related to a database of orders and customers. It includes queries for calculating total, average, maximum, and minimum purchase amounts, counting distinct salesmen and customers, and listing orders based on specific criteria. The document is part of a practical assignment for a Database Management System course.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

MYSQL Assignment-3

The document contains SQL statements and their results related to a database of orders and customers. It includes queries for calculating total, average, maximum, and minimum purchase amounts, counting distinct salesmen and customers, and listing orders based on specific criteria. The document is part of a practical assignment for a Database Management System course.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Name -> Priyanshu Parmar Roll No -> 20-BCA-105

41. Write a SQL statement to find the total purchase


amount for all orders.
Code ->

SELECT SUM(PURCH_AMT)
-> FROM Order_105;
+----------------+
| SUM(PURCH_AMT) |
+----------------+
| 19549.00 |
+----------------+
1 row in set (0.03 sec)

42. Write a SQL statement to find the average purchase


amount of all orders
Code ->

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

SELECT AVG(PURCH_AMT)
-> FROM Order_105;
+----------------+
| AVG(PURCH_AMT) |
+----------------+
| 1954.900000 |
+----------------+
1 row in set (0.00 sec)

43. Write a SQL statement to find the number of


salesman currently listing for all of their customers.
Code ->

SELECT COUNT(DISTINCT SALESMAN_ID)

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

-> FROM Order_105;


+-----------------------------+
| COUNT(DISTINCT SALESMAN_ID) |
+-----------------------------+
| 10 |
+-----------------------------+
1 row in set (0.01 sec)

44. Write a SQL statement to know how many customers


have listed their names.

Code ->

SELECT COUNT(CUST_NAME)
-> FROM Customer_105;

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

+------------------+
| COUNT(CUST_NAME) |
+------------------+
| 10 |
+------------------+
1 row in set (0.02 sec)

45. Write a SQL statement find the number of customers


who gets at least a gradation for
his/her performance.
Code ->

SELECT COUNT(GRADE)
-> FROM Customer_105;
+--------------+
| COUNT(GRADE) |
Database Management System and Design-II Practical [BCA-
4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

+--------------+
| 10 |
+--------------+
1 row in set (0.00 sec)

46. Write a SQL statement to know the maximum


purchase amount of all the orders.
Code ->

SELECT MAX(PURCH_AMT)
-> FROM Order_105;
+----------------+

| MAX(PURCH_AMT) |
+----------------+
| 4000.00 |
+----------------+

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

1 row in set (0.00 sec)

47. Write a SQL statement to know the minimum


purchase amount of all the orders.
Code ->

SELECT MIN(PURCH_AMT)
-> FROM Order_105;
+----------------+
| MIN(PURCH_AMT) |

+----------------+
| 500.00 |
+----------------+
1 row in set (0.00 sec)

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

48. Write a SQL statement to prepare a list with


salesman name, customer name and their cities for the
salesmen and customer who belongs to the same city
Code ->

SELECT Customer_105.CUST_NAME ,
Salesmane_105.NAME , Customer_105.CITY
-> FROM Customer_105 , Salesmane_105
-> WHERE Customer_105.CITY = Salesmane_105.CITY;
+-----------+---------+-----------+

| CUST_NAME | NAME | CITY |


+-----------+---------+-----------+
| Dhvji | John | Bombay |
| Dhvji | David | Bombay |
| Chetna | Johnson | Ahmedabad |
| Aditya | Johnson | Ahmedabad |

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

| Priyanshu | Johnson | Ahmedabad |


| Chetna | Wilson | Ahmedabad |
| Aditya | Wilson | Ahmedabad |

| Priyanshu | Wilson | Ahmedabad |


| Chetna | Andrew | Ahmedabad |
| Aditya | Andrew | Ahmedabad |
| Priyanshu | Andrew | Ahmedabad |
| Dhvji | Manttew | Bombay |
+-----------+---------+-----------+

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

49. Write a SQL statement to make a list with order no,


purchase amount, customer name and their cities for
those orders which order amount between 500 and
2000.
Code ->

SELECT Order_105.ORD_NO , Order_105.PURCH_AMT ,


Customer_105.CUST_NAME ,
-> Customer_105.CITY
-> FROM Customer_105 , Order_105
-> WHERE Order_105.PURCH_AMT BETWEEN 500 AND
2000
-> AND Customer_105.CUSTOMER_ID =
Order_105.CUSTOMER_ID;
+--------+-----------+-----------+-----------+
| ORD_NO | PURCH_AMT | CUST_NAME | CITY |
+--------+-----------+-----------+-----------+
| 1| 1500.00 | Priyanshu | Ahmedabad |
| 2| 2000.00 | Aditya | Ahmedabad |
| 3| 500.00 | Dhvji | Bombay |
| 5| 1550.00 | Priya | Amerli |
| 6| 1800.00 | Preet | Nadiad |

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

| 7| 999.00 | Parth | New York |


| 8| 1200.00 | Piyush | New York |

+--------+-----------+-----------+-----------+

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

50. Write a SQL statement to know which salesman are


working for which customer
Code ->

SELECT Salesmane_105.NAME ,
Customer_105.CUST_NAME
-> FROM Salesmane_105 , Customer_105
-> WHERE Customer_105.SALESMAN_ID =
Salesmane_105.SALESMAN_ID;
+---------+-----------+
| NAME | CUST_NAME |
+---------+-----------+
| John | Priyanshu |
| David | Aditya |
| Drew | Dhvji |
| Johnson | Chetna |
| Steve | Priya |
| Wilson | Preet |
| Max | Parth |
| Andrew | Piyush |
| Jonthan | Ayush |
| Manttew | Samarth |
+---------+-----------+
10 rows in set (0.01 sec)

Database Management System and Design-II Practical [BCA-


4505L]
Name -> Priyanshu Parmar Roll No -> 20-BCA-105

Database Management System and Design-II Practical [BCA-


4505L]

You might also like