SQL Test
SQL Test
Ans) Create table shoe(id int, name varchar(20), price int, size int);
3) Write a query to change the age of the student to 32 years who is Bangalore resident?
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?
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) B (compute)
13) Which data manipulation command is used to combines the records from one or more tables?
Ans) C (join)
Ans) D (in)
17) If we have not specified ASC or DESC after a SQL ORDER BY clause, the following is used by
default?
Ans) B (ASC)
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?