Student Name: Abdulaziz Bakhsh Student ID: 1543123 Database Lab 4
Student Name: Abdulaziz Bakhsh Student ID: 1543123 Database Lab 4
Student ID : 1543123
Database Lab 4
Q : Write a SQL statement to find the total purchase amount of all orders.
Code : SELECT SUM (purch_amt)
FROM orders;
Q : Write a SQL statement to find the average purchase amount of all orders.
Code : SELECT AVG (purch_amt)
FROM orders;
Q : Write a SQL statement to find the number of salesmen currently listing for all of their customers.
Code : SELECT COUNT (DISTINCT salesman_id)
FROM orders;
Lab. Activity – 02:
Q : Write a SQL statement to find the highest purchase amount ordered by the each customer on a
particular date with their ID, order date and highest purchase amount.
Code : SELECT customer_id,ord_date,MAX(purch_amt)
FROM orders
GROUP BY customer_id,ord_date;
Q : Write a SQL statement to find the highest purchase amount ordered by the each customer with their
ID and highest purchase amount.
Code : SELECT customer_id,MAX(purch_amt)
FROM orders
GROUP BY customer_id;
Lab. Activity – 03:
Q : Write a SQL statement to find the highest purchase amount with their ID and order date, for only
those customers who have highest purchase amount in a day is more than 2000.
Code : SELECT customer_id,ord_date,MAX(purch_amt)
FROM orders
GROUP BY customer_id,ord_date
Q : Write a SQL statement to find the highest purchase amount with their ID and order date, for those
customers who have a higher purchase amount in a day is within the range 2000 and 6000.
Code : SELECT customer_id,ord_date,MAX(purch_amt)
FROM orders
GROUP BY customer_id,ord_date
Q2: Write a query to display the current date. Label the column Date
Code: SELECT sysdate "Date"
FROM dual;
Q3: Write a query that displays the last name (with the first letter uppercase and all other letters
lowercase) and the length of the last name for all employees whose name starts with the letters J, A, or
M. Give each column an appropriate label. Sort the results by the employees’ last names.
Q4: Find the highest, lowest, sum, and average salary of all employees. Label the columns Maximum,
Minimum, Sum, and Average, respectively. Round your results to the nearest whole number.