Q1.
Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(i) To create above table as per specification given
(ii) To insert 02 records as per your choice
(iii) Display the Item name , qty & Rates of all items purchased by customer whose custID is C101.
(iv) Delete record of customer ‘Kamala’.
Q2. Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(i) To create above table as per specification given
(ii) Add new column ‘ItemCategory’ to store one Characters only.
(iii) Display the ItemName purchased between dates ’2015-01-22’ and 2015-02-21’ .
(iv) Display customer name who purchased ‘TEA’ from the shop.
Q3. Write SQL query for the following :
Table : SHOP
Field DataType Size Constraints
ItemID CHAR 5 Primary key
ItemName Varchar 30
Qty Int
Rate Int
(i) To create above table as per specification given
(ii) Add new column ‘ItemType’ to store one Characters only.
(iii) To update the table and change the Qty of TEA If item ‘TEA’ sold in qty 50,
(iv) Display ItemName whose Qty is more than 10 but Rate is less than Rs. 100;
.
04
(i) Display Customer No., Customer Address of all customers.
(ii) Display details of Touch Screen phone.
(iii) Insert new record in Customer as per your choice.
(iv) To drop table customer
05. Consider the tables PURCHASE and CUSTOMERS given below:
CUSTOMER
Cust_Id First_Name Last_Name DOB PurchaseAmount
1 Alisha Madan 20/01/1989 200
2 Akhil Sachdeva 01/02/1990 199
3 Rajesh Mehta 10/09/1986 600
Rani Garg 24/11/1986 99
With reference to these tables, write commands in SQL for (i) and (iv)
(i) Display the first name, last name and DOB of all the customers.
(ii) Display the names of all customers whose purchase amount is more than Rs. 200
(iiI) Display Sum of purchase Amount of above table.
(iv) Display First Name whose DOB between 10/09/1986 and 20/01/1989.
Q6. Write the SQL command for (i) to (iv) on the basis of the table SUPPLIER:
Table: SHOP
SNo PName SName Qty Price City
S1 Bread Britannia 150 8.00 Delhi
S2 Cake Britannia 250 20.00 Mumbai
S3 Coffee Nascafe 170 45.00 Mumbai
S4 Chocolate amul 380 10.00 Delhi
S5 Sauce kissan 470 36.00 Jaipur
(i) Display details for all products whose quantity is between 170 and 370.
(ii) Display data for all products sorted by their quantity.
(iii) Display City where City should not repeat.
(iv) Give SName for that entire product whose name starts with “C”.
Q7. Use the following structure of Customer table to write SQL as follows :
Column Name Cust_ID Cust_Name Cust_Add1 Pin_Code Cust_Phone
(Primary
Key)
Data type NUMBER VARCHAR2 VARCHAR2 NUMBER VARCHAR2
Length 7 30 20 6 10
(i) To create the above table including its Constraints.
(ii) To insert a record into created table.
(iii) Add new column in above table as DateOfReg of date type.
(iv) Drop the column Pin_Code
Q8. Consider following tables and write SQL
Table: Emp
EMPNO ENAME JOB HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 02-Apr-81 2975 NULL 20
7654 MARTIN SALESMAN 28-Sep-81 1250 1400 30
7698 BLAKE MANAGER 01-May-81 2850 NULL 30
7782 CLARK MANAGER 09-Jun-81 2450 NULL 10
7788 SCOTT ANALYST 09-Dec-82 3000 NULL 20
(i) To list the EName who is not getting any commission(COMM).
(ii) Display ENAME and SAL of all employee getting salary more that 1000
(iii) Display different jobs available in EMP table.
(Hint : unique jobs)
(iv) Display Name of Employee whose name start with character ‘A’.
Q9. Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(v) To create above table as per specification given
(vi) To insert 02 records as per your choice
(vii) Display the Item name , qty & Rates of all items purchased by customer whose custID is C101.
(viii) Delete record of customer ‘Kamala’.
Q10. Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(v) To create above table as per specification given
(vi) Add new column ‘ItemCategory’ to store one Characters only.
(vii) Display the ItemName purchased between dates ’2015-01-22’ and 2015-02-21’ .
(viii) Display customer name who purchased ‘TEA’ from the shop.
Q11. Write SQL query for the following :
Table : SHOP
Field DataType Size Constraints
ItemID CHAR 5 Primary key
ItemName Varchar 30
Qty Int
Rate Int
(v) To create above table as per specification given
(vi) Add new column ‘ItemType’ to store one Characters only.
(vii) To update the table If item ‘TEA’ sold in qty 50,
(viii) Display ItemName whose Qty is more than 10 but Rate is less than Rs. 100;
.
Q12. Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(ix) To create above table as per specification given
(x) To insert 02 records as per your choice
(xi) Display the Item name , qty & Rates of all items purchased by customer whose custID is C101.
(xii) Delete record of customer ‘Kamala’.
Q13. Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(ix) To create above table as per specification given
(x) Add new column ‘ItemCategory’ to store one Characters only.
(xi) Display the ItemName purchased between dates ’2015-01-22’ and 2015-02-21’ .
(xii) Display customer name who purchased ‘TEA’ from the shop.
Q14. Write SQL query for the following :
Table : SHOP
Field DataType Size Constraints
ItemID CHAR 5 Primary key
ItemName Varchar 30
Qty Int
Rate Int
(ix) To create above table as per specification given
(x) Add new column ‘ItemType’ to store one Characters only.
(xi) To update the table and change the Qty of TEA If item ‘TEA’ sold in qty 50,
(xii) Display ItemName whose Qty is more than 10 but Rate is less than Rs. 100;
.
Q15
(v) Display Customer No., Customer Address of all customers.
(vi) Display details of Touch Screen phone.
(vii) Insert new record in Customer as per your choice.
(viii) To drop table customer
Q16 Consider the tables PURCHASE and CUSTOMERS given below:
CUSTOMER
Cust_Id First_Name Last_Name DOB PurchaseAmount
1 Alisha Madan 20/01/1989 200
2 Akhil Sachdeva 01/02/1990 199
3 Rajesh Mehta 10/09/1986 600
Rani Garg 24/11/1986 99
With reference to these tables, write commands in SQL for (i) and (iv)
(iii) Display the first name, last name and DOB of all the customers.
(iv) Display the names of all customers whose purchase amount is more than Rs. 200
(iiI) Display Sum of purchase Amount of above table.
(iv) Display First Name whose DOB between 10/09/1986 and 20/01/1989.
Q17. Write the SQL command for (i) to (iv) on the basis of the table SUPPLIER:
Table: SHOP
SNo PName SName Qty Price City
S1 Bread Britannia 150 8.00 Delhi
S2 Cake Britannia 250 20.00 Mumbai
S3 Coffee Nascafe 170 45.00 Mumbai
S4 Chocolate amul 380 10.00 Delhi
S5 Sauce kissan 470 36.00 Jaipur
(v) Display details for all products whose quantity is between 170 and 370.
(vi) Display data for all products sorted by their quantity.
(vii) Display City where City should not repeat.
(viii) Give SName for that entire product whose name starts with “C”.
Q18. Use the following structure of Customer table to write SQL as follows :
Column Name Cust_ID Cust_Name Cust_Add1 Pin_Code Cust_Phone
(Primary
Key)
Data type NUMBER VARCHAR2 VARCHAR2 NUMBER VARCHAR2
Length 7 30 20 6 10
(v) To create the above table including its Constraints.
(vi) To insert a record into created table.
(vii) Add new column in above table as DateOfReg of date type.
(viii) Drop the column Pin_Code
Q19. Consider following tables and write SQL
Table: Emp
EMPNO ENAME JOB HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 17-Dec-80 800 NULL 20
7499 ALLEN SALESMAN 20-Feb-81 1600 300 30
7521 WARD SALESMAN 22-Feb-81 1250 500 30
7566 JONES MANAGER 02-Apr-81 2975 NULL 20
7654 MARTIN SALESMAN 28-Sep-81 1250 1400 30
(v) To list the EName who is not getting any commission(COMM).
(vi) Display ENAME and SAL of all employee getting salary more that 1000
(vii) Display different jobs available in EMP table.
(Hint : unique jobs)
(viii) Display Name of Employee whose name start with character ‘A’.
Q22. Write SQL query for the following :
Table : Purchase
Field DataType Size Constraints
CustID CHAR 5 Primary key
CustName Varchar 30
ItemName Varchar 30
PurchaseDate Date
Qty Int
Rate Int
Amount Int
(xiii) To create above table as per specification given
(xiv) To insert 02 records as per your choice
(xv) Display the Item name , qty & Rates of all items purchased by customer whose custID is C101.
(xvi) Delete record of customer ‘Kamala’.