Select chapter



Basics (2.papers)
Data Types (2.papers)
Table-designing (1.papers)
Queries-Commands (3.papers)
String functions (2.papers)
Subqueries (1.papers)
Joins (1.papers)
Constraints (1.papers)
Triggers (1.papers)
Hide

Sponsored Links


  

sql queries commands interview questions and answers

Please read the below given table for solving questions from 1 to 20
eidfnamelnameagesalarydeptdoj
1rajeevsukla2312000.net23-Oct-11 12:00:00 AM
2sowmyakumari2319000db13-Nov-10 12:00:00 AM
3kishorekumar2736000android16-Oct-11 12:00:00 AM
4abimanyubiswal22nullandroid25-May-10 12:00:00 AM
5sonikumar2421800.net21-Jun-09 12:00:00 AM
6anu_singh2212000db23-Oct-10 12:00:00 AM
7_dineshmoh%anty2315000.net26-Aug-09 12:00:00 AM
8nischala_kumari2218000db19-Jul-08 12:00:00 AM
9gouravchourasia2420000android06-Oct-13 12:00:00 AM
Note: Assume table is present in a database named skillgun , the Schema name is dbo and the table name as Employees ;
1
Which of the following queries is used display all the columns data using select statement?
  1. select * from employees ;
  2. select eid,fname,lname,age,salary,dept,doj from employees ;
  3. select e.eid,e.fname,e.lname,e.age,e.salary,e.dept,e.doj from employees e ;
  4. All the above options are correct ;
Show Answer
Share Facebook gmail Twitter
2
Which of the following queries is used to display only few columns(eid ,fullname=fname+lname) using select statement?
  1. select eid,fullname from employees ;
  2. select eid,fname+lname as fullname from employees ;
  3. select * from employees ;
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
3
Which of the below given sql statement is used for producing the following resultset ?
Resultset:
EidFnameLname AgeCountry
1rajeevsukla23India
2sowmyakumari23India
3---------------
--------------
Note: assume relavent data where hyphens are present
  1. select * from employees ;
  2. select eid,fname,lname,age,'India' from employees ;
  3. select eid,fname,lname,age,'India'  as 'Country' from employees ;
  4. It is not possible to display a column which is not existing in the source table in the resultset .
Show Answer
Share Facebook gmail Twitter
4
Which of the following query displays employee full name whose salary is undefined or null ?
  1. select * from employees where salary=null ;
  2. select * from employees where salary='null' ;
  3. select * from employees where salary==null ;
  4. select * from employees where salary is null ;
Show Answer
Share Facebook gmail Twitter
5
Which of the following queries is used to display all the employees whose salary is not equal to null?
  1. select * from employees where salary<> not null ;
  2. select * from employees where salary!=null ;
  3. select * from employees where salary !=not null ;
  4. select * from employees where salary is not null ;
Show Answer
Share Facebook gmail Twitter
6
Which of the following queries is used for displaying all the employees whose salary is more than 15000 ?
  1. select * from employees where salary is > 15000
  2. select * from employees where salary > 15000
  3. select * from employees where salary is greater than 15000
  4. select * from employees where salary greater than 15000
Show Answer
Share Facebook gmail Twitter
7
Which of the following query displays employees details whose salary is between 15000 and 26000 ?
  1. select * from employees where salary between 26000 and 15000
  2. select * from employees where salary between 15000 and 26000
  3. select * from employees where salary>15000 and 26000
  4. select * from employees where salary in (15000,26000) 
Show Answer
Share Facebook gmail Twitter
8
Which of the following query displays employees details whose salary is equal to 12000 or 15000 or 18000 or 20000?
  1. select * from employees where salary=(12000,15000,18000,20000)
  2. select * from employees where salary in (12000,15000,18000,20000)
  3. select * from employees where salary=12000 or salary=15000 or salary=18000 or salary=20000
  4. Both Second and third queries are correct .
Show Answer
Share Facebook gmail Twitter
9
Write a query for displaying the employee fullname whose salary is greater than 16000 and whose age is greater than 23 years ?
  1. select fname+lname as 'fullname' from employees where salary > 16000 &&  age>23
  2. select fname+lname as 'fullname' from employees where salary > 16000 &  age>23
  3. select fname+lname as 'fullname' from employees where salary > 16000 and  age>23
  4. None of the above .
Show Answer
Share Facebook gmail Twitter
10
Identify the correct result set for the below given query ?
Query: select eid,fname+lname,salary*0.2 as bonus,2*10 as 'constant' from employees ;
  1. query will not compile ;
  2. query will compile but will give 
    runtime error while executing the query .
  3. eid(No column name)bonusconstant
    1rajeevsukla2400.020
    2sowmyakumari3800.020
    ----some data----data--20
    ----some data ---- data--20
  4. only data in eid and computed bonus salary is 
    displayed ;
Show Answer
Share Facebook gmail Twitter
11
Which of the following syntax is correct for inserting the below given data into the employees table ?
Eid=10; fname=srilesh; salary=29800;
Note: Assuming no default constraints added to any of the columns.
  1. insert into employees values 
    (10,srilesh,29800) ;
  2. insert into employees values 
    (eid=10,fname='srilesh',salary=29800) ;
  3. insert into employees (eid,fname,salary) values 
    (10,'srilesh',29800) ;
  4. insert into employees values 
    (10,'srilesh',29800) ;
Show Answer
Share Facebook gmail Twitter
12
Which of the following syntax is correct for inserting the below given data into the employees table ?
Eid=11 ; fname=bharath ; salary=32800 ;
Note: Assuming no default constraints added to any of the columns.
  1. insert into employees values 
    (11,'bharath',null,null,32800,null,null) ;
  2. insert into employees values 
    (11,'bharath','null','null',32800,'null','null') ;
  3. insert into employees (eid,fname,salary) values 
    (11,'bharath',null,null,32800,null,null) ;
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
13
Which of the following query returns the employees details whose salaries are not between 15000 and 20000?
  1. select * from employees where 
    salary>20000 or salary<15000
  2. select * from employees where 
    salary not between 15000 and 20000
  3. select * from employees where salary not in (15000,20000)
  4. First and second options are correct.
Show Answer
Share Facebook gmail Twitter
14
Which of the following query will display the employees details based on the descending order of their salaries?
  1. select * from employees where salary in desc
  2. select * from employees order by salary 
  3. select * from employees order by salary desc
  4. select * from employees where salary order by desc
Show Answer
Share Facebook gmail Twitter
15
Which of the following syntax is the correct syntax for using order by clause?
  1. select * from table_name where [condition] order by [list of column names separated by comma] [asc|desc]
  2. select * from table_name order by [list of column names separated by comma] [asc|desc] where [condition] 
  3. select column1,order by column 2,…. from table_name where [condition] 
  4. All the syntaxe's shown in first 3 options are correct .
Show Answer
Share Facebook gmail Twitter
16
Which of the following statement is used for displaying first 3 rows present in the employees table ?
  1. select 3 * from employees ;
  2. select first 3 * from employees;
  3. select top 3 * from employees ;
  4. None of the above .
Show Answer
Share Facebook gmail Twitter
17
Which of the following query is used to display the first highest salary?
  1. select top 1 salary from employees
  2. select top 1 salary from employees order by salary 
  3. select top 1 salary from employees where salary=max(salary)
  4. select top 1 salary from employees order by salary desc
Show Answer
Share Facebook gmail Twitter
18
Which of the following queries is used to copy data present in employees table into another non existing table ( which is not present in database ) ?
  1. select * into new_table_name from existing_tablename
  2. It is not possible to copy data from a table into another table which is not existing before executing the current query
  3. insert into new_table_name select * from existing_table_name
  4. insert into new_table_name values select * from existing_table_name
Show Answer
Share Facebook gmail Twitter
19
Which of the following queries is used to copy data from one table into another table when both the the tables are existing and the table structures are same?
  1. select * from first-table-name into second-table-name
  2. insert into destination-table-name select * from source-table-name
  3. insert into destination-table-name values select * from source-table-name
  4. insert into destination-table-name values ( select * from source-table-name )
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :