DBMS Cat 2
DBMS Cat 2
SCT121-C002-0013/2021
ASSIGNMENT TWO
Question One
Being that the table contains Salesman information, we’ll name the table as “salesman”.
An SQL statement to display all the information of all salesmen.
SELECT * FROM salesman;
Question Two
An SQL statement to display specific columns like name and commission for all the salesmen.
SELECT name, commission
FROM salesman;
Question Three
An SQL statement to display names and city of salesman, who belongs to the city of Paris.
SELECT name,city
FROM salesman
WHERE city='Paris';
Question Four
An SQL statement to find those salesmen with all information who come from the city either
Paris or Rome.
SELECT * FROM salesman
WHERE city='Paris' OR city='Rome';
Question Five
Write a query to filter those salesmen with all information who comes from any of the cities
Paris and Rome.
SELECT * FROM salesman
WHERE city IN('Paris','Rome');
Question Six
Write a query to produce a list of salesman_id, name, city and commission of each salesman who
live in cities other than Paris and Rome.
SELECT * FROM salesman
WHERE city NOT IN('Paris','Rome');
Question Seven
Write a SQL statement to find those salesmen with all information who gets the commission
within a range of 0.12 and 0.14.
SELECT * FROM salesman
WHERE commission BETWEEN 0.12 AND 0.14;
Question Eight
Write a SQL statement to find those salesmen with all other information and name started with
any letter within 'A' and 'K'.
SELECT * FROM salesman
WHERE name BETWEEN 'A' and 'K';
Question Nine
Write a SQL statement to find those salesmen with all other information and name started with
other than any letter within 'A' and 'L'.
SELECT * FROM salesman
WHERE name BETWEEN 'A' and 'L';
Question Ten
Being that the table contains Order information, we’ll name the table as “Orders”.
Write a query to display the columns in a specific order like order date, salesman id, order
number and purchase amount from for all the orders.
SELECT ord_date, salesman_id, ord_no, purch_amt
FROM orders;
Question Eleven
Write a query which will retrieve the value of salesman id of all salesmen, getting orders from
the customers in orders table without any repeats.
SELECT DISTINCT salesman_id
FROM orders;
Question Twelve
Write a SQL query to display the order number followed by order date and the purchase amount
for each order which will be delivered by the salesman who is holding the ID 5001.
SELECT ord_no, ord_date, purch_amt
FROM orders
WHERE salesman_id = 5001;
Question Thirteen
Write a query to filter all those orders with all information which purchase amount value is
within the range 500 and 4000 except those orders of purchase amount value 948.50 and
1983.43.
SELECT *
FROM orders
WHERE (purch_amt BETWEEN 500 AND 4000)
AND NOT purch_amt IN(948.50,1983.43);
Question Fourteen
Write a SQL statement to display a string "This is SQL Exercise, Practice and Solution".
SELECT 'This is SQL Exercise, Practice and Solution';