SQL - Programming Language (MCQ) questions
Dear Readers, Welcome to SQL multiple choice questions and answers with
explanation. These objective type SQL questions are very important for campus placement test and job interviews.
Specially developed for the SQL freshers and professionals, these model questions are asked in the online technical test and interview of many IT companies.
1) Consider the following set of relations
EMP ( emp_no,emp_name,dept_no,salary) DEPT (dept_no,dept_name,location) Write SQL query for the following Find all the employees whose departments are located in 'Mumbai' and salary is greater than Rs. 20,000. - Published on 16 Jun 15
a. select emp_name from dept where dept_no and location='Mumbai';
b. select emp_name from emp where salary > 20,000 and dept_no in (select dept_no from dept where location = 'Mumbai');
c. select dept_no ,count(emp_no) from emp where salary > 50,000 group by dept_no;
d. update table emp where emp_name='Mumbai';
Answer
Explanation
|
ANSWER: select emp_name from emp where salary > 20,000 and dept_no in (select dept_no from dept where location = 'Mumbai');
Explanation: No explanation is available for this question!
|
|
2) From the following statements which of them is/are true about SQL
1. All attributes used in the group by clause must appear in the select clause 2. An SQL query can contain a having clause only if it has a group by clause 3. An SQL query can contain a having clause even if it does not have a group by clause 4. Not all attributes used in the group by clause need to appear in the select clause - Published on 16 Jun 15
a. 3 and 4
b. 1 and 2
c. 1,3 and 4
d. All of the above
Answer
Explanation
|
ANSWER: 3 and 4
Explanation: Statement number 3 is true because it considers the output by select query as a single group if group by statement is not present.
|
|
3) Which SQL command is used to insert a row in a table? - Published on 16 Jun 15
a. Select
b. Create
c. Insert
d. Drop
Answer
Explanation
|
ANSWER: Insert
Explanation: Insert is used to add data to the tables or add rows to the table.
|
|
4) What are the different types of joins?
1. Outer join 2. Inner join 3. Right join 4. Left join 5. Full join
- Published on 16 Jun 15
a. 1 and 3
b. 4 and 5
c. 3,4 and 5
d. All of the above
Answer
Explanation
|
ANSWER: All of the above
Explanation: All these are the different types of joins.
|
|
5) What are the different SQL statements? 1. DML 2. DDL 3. DCL 4. DQL
- Published on 16 Jun 15
a. 1 and 2
b. 2 and 3
c. 3 and 4
d. 1,2 and 3
e. All of the above
Answer
Explanation
|
ANSWER: All of the above
Explanation: All these statements are used to make a sql query.
|
|