1.
Write a SQL statement to display the commission with the
percent sign ( % ) with salesman ID, name and city columns for
all the salesmen.
Sample table : salesman
SELECT salesman_id,name,city,commission,’%’, FROM salesman;
2. Write a SQL statement to find out the number of orders
booked for each day and display it in such a format like "For
2001-10-10 there are 15 orders".
Sample table : orders
SELECT ‘For ‘||ord_date as order_date, COUNT(DISTINCT ord_date)||’ orers’ as orders
FROM orders GROUP BY ord_date;
3. Write a query to display the orders according to the order
number arranged by ascending order.
Sample table : orders
SELECT * FROM orders ORDER BY ord_no;
4.Write a SQL statement to arrange the orders according to the
order date in such a manner that the latest date will come first
then previous dates.
Sample table : orders
SELECT * FROM orders ORDER BY ord_date desc;
5. Write a SQL statement to display the orders with all
information in such a manner that, the older order date will come
first and the highest purchase amount of same day will come
first.
Sample table : orders
SELECT * FROM orders ORDER BY ord_date ,purch_amt desc;
6. Write a SQL statement to display the customer name, city and
grade, etc. and the display will be arranged according to the
smallest customer ID.
Sample table : customer
SELECT name,city,grade FROM customer ORDER BY customer_id;
7. Write a SQL statement to make a report with salesman ID,
order date and highest purchase amount in such an arrangement
that, the smallest salesman ID will come first along with their
smallest order date.
Sample table : orders
SELECT salesman_id,ord_date,max(purch_amt) FROM orders GROUP BY
salesman_id,ord_date ORDER BY salesman_id,ord_date;
8. Write a SQL statement to display customer name, city and
grade in such a manner that, the customer holding highest grade
will comes first.
Sample table : customer
SELECT cust_name,city,grade FROM customer ORDER BY grade
desc;
9. Write a SQL statement make a report with customer ID in
such a manner that, the largest number of orders booked by the
customer will comes first along with their highest purchase
amount.
Sample table : orders
SELECT customer_id, count(distinct ord_no), max(purch_amt)
from orders group by customer_id ORDER BY count(distinct
ord_no) desc;
10. Write a SQL statement to make a report with order date in
such a manner that, the latest order date will comes first along
with the total purchase amount and total commission (15% for all
salesmen) for that date.
Sample table : orders
SELECT ord_date , SUM(purch_amt),SUM(purch_amt)*0.15 as commission FROM orders
GROUP BY ord_date ORDER BY ord_date;