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 interview questions and answers

1
What is the use of a join in SQL?
  1. Joins in SQL can be used for retrieving data from two or more tables into the result set.
  2. Joins in SQL can be used for comparing data present in a table with another tables data.
Show Answer
Share Facebook gmail Twitter
2
Which of the following joins are supported in SQL?
  1. Inner join and Outer join.
  2. Cross join and Self join.
  3. Left outer join, right outer join and full outer join.
  4. All the joins are supported in SQL.
Show Answer
Share Facebook gmail Twitter
3
What is an inner join?
  1. An inner join is a type of join in which matched (as per the on condition) records from both the tables will be displayed.
  2. All rows present in all tables participating in join will be displayed in the result set irrespective of the condition.
  3. All rows from left table and only matched rows from right table will be displayed in the result set.
  4. Joining a table to itself is called as an inner join.
Show Answer
Share Facebook gmail Twitter
4
Which of the following syntax is the correct syntax for inner join?
  1. select t1.colum1,t1,column2,..,t2.column1,t2.column2 from table_name t1 join table_name t2 on <join_condition>;
  2. select t1.colum1,t1,column2,..,t2.column1,t2.column2 from table_name t1 inner join table_name t2 on <join_condition>;
  3. First and second syntax's are valid for inner join.
Show Answer
Share Facebook gmail Twitter
Please read the below given tables for solving questions from 5 to 13
trainingidcoursenameeidtrainingdate
1sql301-Oct-13
2c#221-Oct-13
3sql310-Dec-13
4sql226-Oct-13
5sql418-Oct-12
6c#412-Oct-13
7java426-Jan-14
eidnamedojsalary
1tony02-Oct-1220000
2suresh12-Jan-1230000
3mahesh11-Jan-1225000
4madhav04-Feb-1128000
5
Which of the following queries return all the employee names, joining dates and attended course names?
  1. select e.name,t.trainingdate,t.coursename from employees e inner join trainings t on e.doj=t.trainingdate
  2. select e.name,t.trainingdate,t.coursename from employees e inner join trainings t on e.eid=t.eid 
  3. select e.*,t.* from employees e , trainings t on e.eid=t.eid ;
  4. select e.name,t.trainingdate,t.coursename from employees e ,trainings t 
Show Answer
Share Facebook gmail Twitter
6
Which of the following queries return the employee names who has attended more than one training?
  1. select e.name from employees e join trainings t on e.eid=t.eid group by e.name having (count(t.coursename)>1)
  2. select e.name from employees e join trainings t on e.eid=t.eid group by e.name having (count(t.eid)>1)
  3. select e.name from employees e join trainings t on e.eid=t.eid group by e.name having (count(*)>1)
  4. All the queries are correct
Show Answer
Share Facebook gmail Twitter
7
Which of the following queries return the employee names who has attended any training more than once?
  1. select e.name from employees e join trainings t on e.eid=t.eid group by e.name having (count(*)<>count(distinct coursename))
  2. select e.name from employees e join trainings t on e.eid=t.eid group by e.name having (count(distinct coursename)>1)
  3. select e.name from employees e join trainings t on e.eid=t.eid group by e.name having (count(coursename)>1)
  4. None of the options are correct .
Show Answer
Share Facebook gmail Twitter
8
Which of the following statement is correct about left outer join?
  1. In Left outer join all records from left side table will come into the result set , but only the matched records from right side table will come into the result set .
  2. Incase of left outer join the minimum row count is always greater than or equal to the total number of rows in left side table if there is no filter condition specified in the join ( using where or having clause ).
  3. First and second statements are valid.
Show Answer
Share Facebook gmail Twitter
9
Which of the following queries return all the employee names along with the attended coursenames if any?
  1. select e.name,t.coursename from employees e left outer join trainings t 
  2. select e.name,t.coursename from employees e left outer join trainings t on e.eid=t.eid 
  3. select e.name,t.coursename from trainings t left outer join employees e on e.eid=t.eid 
  4. None of the options are correct .
Show Answer
Share Facebook gmail Twitter
10
Which of the following statement is correct about Right outer join?
  1. In Right outer join all records from right side table and only the matched records from left side table will come into the result set (if there is no filter condition like where or having clauses).
  2. Incase of right outer join the minimum row count is always greater than or equal to the total number of rows in right side table if there is no filter condition specified in the join (using where or having clause).
  3. First and second statements are valid left outer join.
Show Answer
Share Facebook gmail Twitter
11
Which of the following queries return all the employee names along with the attended coursenames if any ?
  1. select e.name,t.coursename from employees e right outer join trainings t 
  2. select e.name,t.coursename from employees e right outer join trainings t on e.eid=t.eid 
  3. select e.name,t.coursename from trainings t right outer join employees e on e.eid=t.eid 
  4. None of the options are correct .
Show Answer
Share Facebook gmail Twitter
12
What is a self join?
  1. A self join is a normal join in which a table data will be joined to itself.
  2. A self join will be suitable for a comparing a table column values with itself.
  3. Both the statements are correct.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
13
Which of the following self join syntax is a valid self join syntax?
  1. select column_name[s] from table_name t1 self join same_table_name_as_first_table t2 on <condition>
  2. select column_name[s] from table_name t1 join same_table_name_as_first_table t2 on <condition>
  3. select column_name[s] from table_name t1 inner join same_table_name_as_first_table t2 on <condition>
  4. Second and third options are correct.
Show Answer
Share Facebook gmail Twitter
14
which of the following query will return all the product names which are supplied by more than one vendor ?
Table:
pidpnamevendorIdpriceVendorName
1NoteBook225ITC
2Dove150HUL
1NoteBook122Godrej
3Minto21ITC
4Locks3190Godrej
4Locks1180HUL
3Minto21ITC
  1. select p1.pname from products p1 join products p2 
    on p1.pname=p2.pname and p1.vendorname<>p2.vendorname
  2. select p1.pname from products p1 join products p2 
    on p1.pname=p2.pname and p1.vendorname=p2.vendorname
  3. select p1.pname from products p1 join products p2 
    on p1.pname!=p2.pname and p1.vendorname=p2.vendorname
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
15
which of the below given query will return the employee names whose experience is greater than their managers experience (Consider the following table as the base table ) ?
Table:
eidnameexperienceMgrid
1Ravi73
2Kishore121
3Pankaj64
4Sanjay135
5Ramu15 
  1. select e.name from empmgrs e join empmgrs e1 on e.mgrid=e1.eid and e.experience>e1.experience
  2. select e.name from empmgrs e join empmgrs e1 on e.eid=e1.mgrid and e.experience>e1.experience
  3. select e.name from empmgrs e join empmgrs e1 on e.eid=e1.mgrid and e.experience<e1.experience
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
16
What is a cross join?
  1. cross join returns cartesian product of rows from tables in the result set.
  2. cross join joins each row from first table with each row in the second table.
  3. cross join will act as a normal inner join if a where clause is defined.
  4. All the options are correct.
Show Answer
Share Facebook gmail Twitter
17
Considering the below given tables identify the output for the following query ?
Query :
cidcnamestateid
1bangalore2
2mysore1
3hosur3
sidstatename
1karnataka
2tamilnadu
3maharastra
4kerala
5Jharkand
  1. cidcnamestateidsidstatename
    1bangalore21karnataka
    1bangalore22tamilnadu
    1bangalore23maharastra
    1bangalore24kerala
    1bangalore25Jharkand
    2mysore11karnataka
    2mysore12tamilnadu
    2mysore13maharastra
    2mysore14kerala
    2mysore15Jharkand
    3hosur31karnataka
    3hosur32tamilnadu
    3hosur33maharastra
    3hosur34kerala
    3hosur35Jharkand
  2. cidcnamestateidsidstatename
    1bangalore21karnataka
    1bangalore22tamilnadu
    1bangalore23maharastra
    1bangalore24kerala
    1bangalore25Jharkand
    2mysore11karnataka
    2mysore12tamilnadu
    2mysore13maharastra
  3. None of the output is correct .
Show Answer
Share Facebook gmail Twitter
Read more papers :