0% found this document useful (0 votes)
10 views

SQL Cbse Best

Uploaded by

Shreya Ajith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

SQL Cbse Best

Uploaded by

Shreya Ajith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

complete sql

program solution
1. Consider the following tables Product and Client. Write SQL
commands for the statements (i) to (iii) and give outputs for SQL
queries (iv) to (vi).
(i) To display the details of those Clients whose city is Delhi.

(ii) display the details of Products whose Price is in the range of 50 to


100 (both values included). whose name ends with 'Wash

(iii) To display the details of those products whose name ends with
“wash”
(IN) SELECT DISTINCT City FROM CLIENT:

(v) SELECT Manufacturer, MAX(Price), MIN(Price), COUNT(*) FROM


PRODUCT GROUP BY Manufacturer;

(vi) SELECT Product Name, Price 4 FROM PRODUCT:


Consider the following table named SBOP with details of account
holders. Write commands of MySql for (i) to (iv) and output for (v) to
(vii).
(i) To display Accountno, Name and DateOfopen of account holders
having transactions more than 8.
(ii) To display all information of account holders whose transaction
value is not mentioned.
(iii) To add another column Address with datatype and size as
VARCHAR(25).
(iv) To display the month day with reference to DateOfopen for all the
account holders.

(v) SELECT COUNT (*) FROM SBOP;


(vi) SELECT Name, Balance FROM SBOP WHERE Name LIKE “%i”;
(vii) SELECT ROUND (Balance,-3) FROM SBOP
WHERE Accountno="SB-5” ;
Consider the following table named EXAM with details of marks. Write
command of MySQL for (i) to (iv) and output for (v) to (vii).
Table EXAM
(i) To display all information of the students of humanities in
descending order of percentage.
(ii) To display Adno, Name, Percentage and Stream of those students
whose name is less than 6 characters long.
(iii) To add another column Bus_Fees with datatype and size as
Decimal(8,2).
(iv) To increase percentage by 2% of all the Humanities students. (All
India 2014)

(v) SELECT COUNT(*) FROM EXAM;


(vi) SELECT SName, Percentage FROM EXAM WHERE Name LIKE “N%”;
(vii) SELECT ROUND (Percentage ,0) FROM EXAM
WHERE Adno=“R005”;
Consider the table SHOPEE given below. Write commands in MySQL for
(i) to (iv) and output for (v) to (vii).
TABLE SHOPEE
(i) To display names of the product, whose name starts with ‘C’ in
ascending order of Price.
(ii) To display code, product name and City of the products whose
quantity is less than 100.
(iii) To count distinct Company in the table.
(iv) To insert a new row in the table SHOPEE.
110, ‘Pizza’, ‘Papa Jones’, 120, ‘Kolkata’, 50.00 (All India 2012)
v) SELECT Pname FROM SHOPEE WHERE Pname IN (‘Jam’, ‘Coffee’);
(vi) SELECT COUNT(DISTINCT City) FROM SHOPEE;
(vii) SELECT MAX(Qty) FROM SHOPEE WHERE City = ‘Mumbai’
Consider the table PERSONS given below. Write commands in SQL for
(i) to (iv) and write output for
(v) to (viii).
TABLE PERSONS
(i) Display the SurName, FirstName and City of people residing in
Udhamwara city.
(ii) Display the Person IDs (PID), Cities and Pincode of persons in descending
order of Pincode.
(iii) Display the FirstName and City of all the females getting Basic salaries
above 40000.
(iv) Display FirstName and BasicSalaries of all the persons whose first name
start with ‘G’. (Delhi 2012c)

(v) SELECT SurName FROM PERSONS WHERE BasicSalary>= 50000;


(vi) SELECT SUM (BasicSalary) FROM PERSONS WHERE Gender = ‘F’;
(vii) SELECT Gender, MIN (BasicSalary) FROM PERSONS GROUP BY Gender;
(viii) SELECT Gender, COUNT (*) FROM PERSONS
GROUP BY Gender;
Consider the table LIBRARY given below. Write commands in MySQL for
(i) to (iv) and output for (v) to (vii).
TABLE LIBRARY
(i) To list the BookTitle of FND type.
(ii) To display a report listing BookTitle, Type and Price in descending
order of price.
(iii) To count the number of BookTitle, Who have FND type.
(iv) To insert a new row in the table LIBRARY.
7, ‘Windows 8 Basics’, ‘FND’,’McGraw’, 7,150.

(v) SELECT AVG(Price) FROM LIBRARY WHERE Type = ‘FND’;


(vi) SELECT COUNT(DISTINCT Type) FROM LIBRARY;
Consider the table STUDENT given below. Write commands in MySQL
for (i) to (iv) and output for (v) to (vii). (HOTS)
TABLE STUDENT
(i) To list the StudentName of Science Stream.
(ii) To display a report listing StudentName, Class and Stream in
ascending order of StudentName.
(iii) To count the number of students to Science Stream.
(iv) To insert a new row in the table STUDENT.
7, ‘Simran Kaur’,’X!l’, ‘Commerce’, 86, ‘A2’

(v) SELECT AVG(AggMarks) FROM STUDENT WHERE Stream=‘Science’;


(vi) SELECT COUNT (DISTINCT Stream) FROM STUDENT;
(vii) SELECT MIN(AggMarks) FROM STUDENT;
What are the basic steps to connect Python with Mysql using table
members present in the database society?
Write a Python Mysql connectivity program to retrieve all the data from
student table
ABC school is managing student data in student table in the school
database. Write a python code that connects to database school and
displays the record of total number of students.

You might also like