Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Practical File

Submitted by: Submitted to:

ACKNOWLEDGEMENT

A project is a golden opportunity for learning and self-


development. We consider ourselves fortunate and
privileged to have such wonderful mentors guide us
through the journey for the completion of the project.
Our sincere thanks to, who despite being extraordinarily
busy took time out to address us and guide us.
Our heartfelt gratitude to our Teacher Guide, for her
patience and belief in us. Her exemplary investment in the
complete process, constant encouragement and insightful
feedback helped us achieve our objectives.
We would also like to thank The Principal and faculty of ,
for allowing us to conduct our research and amidst them.
Lastly, we would like to thank our family members whose
support helped us to complete the project within the
deadline.

Q1. Write the output of the following command

Select round (49.88);

Q2. Consider the following table:


(i) State the command that will dive the output as:

Ans. Select name from students where city = “Agra” or city = “Mumbai”;

(ii) What will be the output of the following command ?


Select * from students where gender = “Female” order by marks;

(iii) Prachi has given the following command to obtain highest marks
select max(marks) from students where group by class;
But she is not getting the desired result. Help her by writing the correct
command.

Ans. select class, max(marks) from students group by class;


(iv) State the command to display the average marks scored by students of
each gender who are in class XI ?
Ans. select gender, avg(marks) from students where class= “XI” group

By gender;

(v) Help Ritesh to write the command to display the name of the youngest
student ?

Ans. select name, min(DOB) from students group by name;

Q3. A relation vehicle is given below:

Write SQL commands to:

(i) Display the average price of each type of vehicle having quantity more
than 20.

Ans. select avg(Price) from vehicle group by Qty having Qty > 20;

(ii) Count the type of vehicles manufactured by each company.

Ans. select Company, count(Distinct name) from vehicle group by Company;

(iii) Display the total price of all types of vehicles.

Ans. select name, sum(Price*Qty) form vehicle group by name;

Q4. Consider a table SALESMAN with the following data:


(i) Display salesman name and bonus after rounding off to zero decimal
places.

Ans. select SNAME, round(Bonus) from SALESMAN;

(ii) Display the position of occurrence of the string “ta” in salesman names.

Ans. select instr(SNAME, “ta’) from SALESMAN;

(iii) Display four characters from salesman name starting from second
character.

Ans. select mid(SNAME, 2, 4) from SALESMAN;

(iv) Display the month name of the date of join of salesmam.

Ans. select monthname(DateOfJoin) from salesman;

(v) Display the name of the weekday for the date of join of the salesman.

Ans. select dayname(DateOfJoin) from SALESMAN;

Q5. Predict the output of the following queries:

(i) select instr(‘exam@cbse.nic.in’, “.”);

(ii) select substr(‘exam@cbse.nic.in’, 7, 4);


(iii) select left(‘exam@cbse.nic.in’, 5);

Q6. Carefully observe the following table “stock”:

Write SQL queries for the following:

(i) To display the record in decreasing order of price.

Ans. select Price from stock order by Price DESC;

(ii) To display category and category wise total quantities of products.

Ans. select Category, Qty from stock order by Category;

(iii) To display the category and its average price.

Ans. select Category, avg(Price) from stock group by Category;

(iv) To display category and category wise highest price of the products.

Ans. select Category, max(Price) from stock group by Category;

Q7. Write output for SQL queries which are based on the given table PURCHASE:
(i) select length(CName) from purchase Where Quantity > 100;

(ii) select CName from purchase where DOB = 3;

(iii) select MOD(Quantity, day(DOB)) from purchase where City =


“Chandigarh” ;

Q8. Write suitable SQL queries for the following:

(i) Display 7 characters extracted from 7 left character onwards from the
string “INIDA SHINING”.

Ans. select mid(“INDIA SHINING”, 7, 7);

(ii) Display the position of occurrence of string “COME” in the string


“WELCOME WORLD”.

Ans. select instr(“WELCOME WORLD”, “COME”);

(iii) Round off the value 23.78 to one decimal place.

Ans. select round(23.78, 1);


(iv) Display the remainder of 100 divided by 9.

Ans. select mod(100,9);

Q9. Shreya, a database administrator has designed a database fro a clothing

shop. Help her by writing answers of the following questions based on the

given table:

(i) Write a query to display cloth names in lower case.

Ans. select lower(CName) from cloth;

(ii) Write a query to display the lowest price of the cloths.

Ans. select min(Price) from cloth;

(iii) Write a query to count total number of cloths purchased of medium size.

Ans. select sum(Price) from cloth group by Size having Size = “M”;

Q10. Consider the given SQL string:

“12#All The Best!”

Write suitable SQL queries for the following:

(i) Returns the position of the first occurrence of the substring “The” in the
given string.
Ans. select instr(“12#All The Best!”, “The”);

(ii) To extract last five characters from the string.

Ans. select right(“12#All The Best!”, 5);

Q11. Write suitable SQL queries for the following:

(i) To calculate the exponent for 3 raised to the power of 4.

Ans. select power(3,4);

(ii) To display current date and time.

Ans. select now();

(iii) To round off the value -34.4567 to 2 decimal place.

Ans. select round(-34.4567, 2);

(iv) To display the length of the string “FIFA World Cup”.

Ans. select length(“FIFA World Cup”);

You might also like