SQL Programs For Class 12th C++ Practical File
SQL Programs For Class 12th C++ Practical File
Table:Item
Table:Customer
SOLUTIONS:
Laptop 58000 2
Personal 38000 3
Computer
****************************************END*************************************
**********************************************************************************
Q.Write a SQL queries for (1) to (4) and find outputs for SQL queries (5) to (8),
TABLE : VEHICLE
105 SUV 40
104 CAR 20
TABLE : TRAVEL
KM is Kilometer Travelled
(2) To display the NAME of all the travellers from the table TRAVEL who are
travelling by vehicle with code 101 or 102.
(3) To display the NO and NAME of those travellers form the table TRAVEL
who travelled between ‘2015-12-31’ and ‘2015-04-01’.
(4) To display all the details from table TRAVEL for the travellers, who have
travelled distance more than 100KM in ascending order of NOP.
SOLUTION
FROM TRAVEL
ORDER BY NO DESC;
(2)SELECT NAME
FROM TRAVEL
FROM TRAVEL
(4)SELECT*
FROM TRAVEL
ORDER BY NOP;
(5)2 101
2 102
(6)101
103
102
104
105
(8)Raveena 3200
****************************************END*************************************
**********************************************************************************
Q. Given the following student relation. Write SQL commands for (1) to (5) and
write output for (6).
(2)To list the names of female students who are in Hindi department
(3)To list the names of all students with their date of admission in ascending
order.
(4)To display student’s Name, Fee, Age, for male Students only.
(6)To inset a new row in the STUDENT table with the following data:
9,”Zaheer”,36,”Computer”,{12/03/97},230,”M”
(1)SELECT*
FROM Student
WHERE Department=”History”;
(2)SELECT Name
FROM Student
(3)SELECT Name
FROM Student
ORDER BY Dateofadm;
FROM Student
WHERE sex=”M”;
(5)SELECT COUNT(*)
FROM Student
WHERE Age<23;
VALUES(9,”Zaheer”,”Computer”,{12/03/97},230,”M”);
(7)
(7.1)3
(7.2)25
(7.3)236
(7.4)1080
****************************************END*************************************
**********************************************************************************
Q. Study the following tables DOCTOR and SALARY .Write SQL commands for
the statements (1) to (4) and give output for the SQL queries(5) to (6).
TABLE:DOCTOR
TABLE:SALARY
(1)Display NAME of all Doctors who are in “MEDICINE” having more than 10
years experience from the table DOCTOR.
(2)Display the average salary of all doctors working in “ENT” department using
table DOCTOR and SALARY.Salary=BASIC+ALLOWANCE.
(1)SELECT Name
FROM Doctor
(2)SELECT AVG(Basic+Allowance)
(3)SELECT MIN(Allowance)
(4)SELECT MAX(CONST)
(5)count(*)
****************************************END*************************************
**********************************************************************************
Q.Given the following tables for a database LIBRARY . Write SQL queries for (1)
to (6).
Table:BOOKS
Table:ISSUED
BOOK_ID QUANTITY_ISSUED
T0001 4
C0001 5
F0001 2
(1)To show book name ,author name and price of books of first
publ.publishers.
(3)To display the names and price from books in ascending order of their
price.
(5)To display the Book_Id,Book_Name and Quantity_Issued for all books which
have been issued.
(6)To insert a new row in the table Issued having the following data:
"F0003",1.
Solutions:
(1)SELECT Book_Name,Author_Name,Price
FROM Books
(2)SELECT Book_Name
FROM Books
(3)SELECT Book_Name,Price
FROM Books
ORDER BY Price;
(4)UPDATE Books
(5)SELECT Books.Book_Id,Book_Name,Quantity_Issued
FROM Books,Issued
VALUES("F0003",1);
****************************************END*************************************