0% found this document useful (0 votes)
9 views10 pages

Xii Ip SQL Board QS 2024-25 With Answers

The document outlines SQL commands for creating and manipulating databases, specifically for mobile, trainer, faculty, watches, and student tables. It includes commands for creating tables, inserting records, and various queries to retrieve and manipulate data based on specific conditions. The document serves as a practical exam for SQL database management and querying techniques.

Uploaded by

abhijithep2024
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)
9 views10 pages

Xii Ip SQL Board QS 2024-25 With Answers

The document outlines SQL commands for creating and manipulating databases, specifically for mobile, trainer, faculty, watches, and student tables. It includes commands for creating tables, inserting records, and various queries to retrieve and manipulate data based on specific conditions. The document serves as a practical exam for SQL database management and querying techniques.

Uploaded by

abhijithep2024
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/ 10

Create database practexam;

Use practexam;

Create table Mobilemaster(Mid char(6),Mcompany char(15),Mname

char(10),Mprice int, Mfdate date);

Insert into Mobilemaster values(‘’MB001’,’ SAMSUNG’, GALAXY’,

4500,2023/02/01’);

(INSERT REST OF THE RECORDS IN THE SAME FORMAT)

1)Display the Mobile company, Mobile name & price in descending order

of their manufacturing date.

Ans. SELECT M_Compnay, M_Name, M_Price FROM MobileMaster


ORDER BY M_Mf_Date DESC;

(ii) List the details of mobile whose name starts with “S”.

Ans. SELECT * FROM MobileMaster

WHERE M_Name LIKE “S%‟;

(iii) Display the Mobile company & mobile name of all mobiles

except “MB003‟.

Ans.SELECT M_company, M_name FROM Mobilemaster

WHERE M_Id <>”MB003”;

(iv) To display the name of mobile company having price between 3000 &

5000.

Ans. SELECT M_Company FROM MobileMaster

WHERE M_Price BETWEEN 3000 AND 5000;

(v) To display the sum of price of those mobile phones whose price is more

than 5000

Ans:SELECT SUM(M_price) FROM Mobile Master where m_price>5000;

vi) Display the length of values in M_name column

Ans: Select length(M_name) from MobileMaster;

vii) Extract the year from M_Mf_date column

Ans: Select year(M_Mf_date) from MobileMaster ;


Create database practexam;

Use practexam;

Create table trainer(Tid int,Tname char(10),city char(15), Hiredate date,

Salary int);

Insert into trainer values(101,,’Suman’,’Mumbai’, ,2023/12/11’,90000);

(INSERT REST OF THE RECORDS IN THE SAME FORMAT)

i. Display the Trainer Name, City & Salary in descending order of

theirHiredate.
Ans. SELECT TNAME, CITY, SALARY FROM TRAINER

ORDER BY HIREDATE;

ii. To display the TNAME and CITY of Trainer who joined the Institute in

before 2001-12-21.

Ans. SELECT TNAME, CITY FROM TRAINER

WHERE HIREDATE <’2001-12-21’;

iii. To display TNAME &HIREDATE, from tables TRAINER of all those

trainers whose salary is greater than or equal to 80000.

Ans. SELECT TNAME,HIREDATE FROM TRAINER

WHERE salary >80000;

iv. To displaycity and number of Trainers from each city.

Ans. SELECT CITY, COUNT(*) FROM TRAINER

GROUP BY CITY;

v) Display the TId & Tname from trainer table Whose city is not Delhi and

mumbai

Ans SELECT TID, TNAME, FROM TRAINER WHERE CITY NOT IN(‘DELHI’,

‘MUMBAI’);
vi) Concatenate the contents of the columns Tname and city columns
Ans: Select concatenation(Tname,city) from trainer;

vii) Display the first 3 characters and last three characters from city
columns
Ans: Select left(city, 3),right(city, 3) from trainer;;

Create database practexam;

Use practexam;

Create table faculty(Fid int,Fname char(10),Lname char(15), Hiredate date,

Salary int);

Insert into trainer values(101,,’Amit’,,’Mishra, ,2023/12/11’,90000);

(INSERT REST OF THE RECORDS IN THE SAME FORMAT)


i) To display details of those Faculties whose salary is greater than 12000.

Ans: Select * from faculty

where salary > 12000;

ii) To display the details of those faculties whose fname ends with ‘t’

Ans: Select * from faculty

where Tname like ‘%t’;

iii ) To increase the salary of the faculties by 500 of “FID 102.

Ans: Update faculty set fees = fees + 500

where fid=102;

(iv) To display details of those faculties who were hired befored 2001-5-18

in descending order of salary.

Ans: Select * from faculty

where hiredate<’2001-05-18’

order by salary desc;

v) Display the count faculties whose salary is more than 10000

Ans:Select COUNT( F_ID) from faculty where salary>10000;


vi) Find out the position of letter ‘a’ in the lname column

Ans: Select instr(lname, ‘a’) from faculty;

vii) Display the month from hiredate column values

Select month(hiredate) from faculty;

SQL 4

i. To display all the details of those watches whose name ends with ‘Time’

Ans select * from watches

where watch_name like ‘%Time’;

ii. To display watch’s name and price of those watches which have price

range in between 5000-15000.

Ans. select watch_name, price from watches

where price between 5000 and 15000;

iii. To display total quantity in store of Unisex type watches.


Ans. select sum(qty_store) from watches where type like ’Unisex’;

iv. To display watch name and their price of W001,W003and W005

Ans. select watch_name,price from watches

where is atchid in(‘W001’,’W003’,W005’)

v. Display the minimum and maximum qty in store from the above table

Ans:select max(price), min(qty_store) from watches;

vi) Extract three characters from the second position of watchname column

Ans: Select substr(watchname, 2,3) from watches;

vii) Find out the square of values in qty in store

Ans: Select pow(qty_store,2) from watches;

SQL 5
(i) To display the records from table student in alphabetical order as per the

name of the student.

Ans. Select * from student

order by name;

(ii ) To display Class, Dob and City whose marks is between 450 and 551.

Ans. Select class, dob, city from student

where marks between 450 and 551;

(iii) To display Name, Class and total number of students who have secured

more than 450 marks, class wise

Ans. Select name,class, count(*) from student

group by class

having marks> 450;

(iv) To increase marks of all students by 20 whose class is “XII


Ans. Update student

set marks=marks+20

where class=’XII’;

(v)Display name and gender of those students whose city is Delhi

SELECT NAME,GENDER FROM STUDENT WHERE CITY=’Delhi’;

Vi) Display the average mark of those students whose city is Delhi

Ans: Select avg(mark) from student where city=’Delhi’;

vii) Display the length of the values in city columns

Ans: Select length(city) from student;

You might also like