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

SQL Test

Uploaded by

gorantlaashok845
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)
5 views

SQL Test

Uploaded by

gorantlaashok845
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/ 3

1) Write a query to create a shoe table that should contain fields like shoe id, shoe name, shoe

price, shoe size?

Ans) Create table shoe(id int, name varchar(20), price int, size int);

2) Write a query to remove the column city from employee table?

Ans) Alter table employee drop column city;

3) Write a query to change the age of the student to 32 years who is Bangalore resident?

Ans) Update student set age = 32 where city = ‘Bangalore’;

4) Write a query to display the youngest person in the student table?

Ans) select name,age from student where age = (select min(age) from student);

5) Write a query to display the names of the mobiles from mobile table whose name starts with
o and the cost of the mobile should be more than 250000?

Ans) Select name from mobiles where name like ‘o%’ and cost>250000;

6) Write a query to change the address of the persons from Hyderabad to Telangana in the
employee table?

Ans) Update employee set address = ‘Telangana’ where address = ‘Hyderabad’;

7) Write a query to display the second highest salary in the employee table?

Ans) Select salary from employee order by salary desc limit 1,2;

8) Write a query to display the costs of all the mobiles with names in descending order of their
prices?
Ans) Select price,name from mobiles order by price desc;

9) Write a query to display the count of laptops based on the released year?

Ans) Select name , (select count(name) from laptop) from laptop group by year;

10) Write a query to display the name of the companies and the total amount, it is paying to
employees based on the their location

Example: Assume that x-company is paying 1cr to hyd employees and 20 lakhs for Bangalore
employees and soon?

Ans) Select name,(select sum(salaries) from employee) from employee group by


location;

11) How many Primary keys can have in a table?

Ans) A (only one)

12) Which of the following is not a valid aggregate function?

Ans) B (compute)

13) Which data manipulation command is used to combines the records from one or more tables?

Ans) C (join)

14) Which operator is used to compare a value to a specified list of values?

Ans) D (in)

15) What operator tests column for absence of data?

Ans) C (IS NULL Operator)

16) In which of the following cases a DML statement is not executed?

Ans) B (When a table is deleted.)

17) If we have not specified ASC or DESC after a SQL ORDER BY clause, the following is used by
default?
Ans) B (ASC)

18) Which of the following is also called an INNER JOIN?

Ans) B (EQUI JOIN)

19) _______ clause creates temporary relation for the query on which it is defined?

C (where)

20) How can you change "Thomas" into "Michel" in the "LastName" column in the Users table?

Ans) D (UPDATE Users SET LastName = 'Michel' WHERE LastName = 'Thomas’)

You might also like