1.

In SQL, which of the following statements is not correct?

2.

You have two tables called Employee and Department.

Employee

Field Type
EmployeeId int
EmployeeName text
DepartmentId int

Department

Field Type
DepartmentId int
DepartmentName text

Sample:

Employee

EmployeeId EmployeeName departmentId
1 Mark 1
2 John 1
3 Mike 1
4 Mary 2
5 Stacy 2

Sample:

Department

DepartmentId DepartmentName
1 IT
2 HR
3 Payroll
4 Admin

Sample Output

DepartmentName EmployeeName
IT Mark
IT John
IT Mike
HR Mary
HR Stacy

Using the Employee and Department tables, which of the following queries will return the same sample output?

1. select DepartmentName,EmployeeName from Employee JOIN Department onDepartments.DepartmentId=EmployeeId.DepartmentId;
2. select DepartmentName,EmployeeName from Employee LEFT JOIN Department onDepartments.DepartmentId=EmployeeId.DepartmentId;
3. select DepartmentName,EmployeeName from Employee RIGHT JOIN Department onDepartments.DepartmentId=EmployeeId.DepartmentId;
3.

Which SQL query will return the minimum salary of employees from the following table?

Employee

Field Type
Name text
Salary Int
 

Sample:

Sample Employee

Name ID
Mark 2000
John 4000
Bob 6000
Alan 8000
Ben 10000
Mary 12000
Alice 14000
 

Sample Output

MIN
2000
4.

Based on the following table, what is the output of these SQL queries:

Table: EMPLOYEE

ID NAME AGE SALARY
01 Ben 24 15000
03 Bob 23 10000
05 Mike 28 15000
02 Alice 26 30000
04 Tara 29 20000
 
SQL > INSERT INTO EMPLOYEE (ID, NAME)VALUES(10,'Anita');

SQL > SELECT * FROM EMPLOYEE;
5.

Based on the following table, what is the output of the SQL query:





 
 

STUDENT |ID|NAME|AGE| 
|:-:| 
|015|Bob|20| 
|020|Alice|18| |105|Mike|25| |151|Tara|NULL|





 
 
SQL > ALTER TABLE STUDENT RENAME TO S1;
6.

Based on the following tables, what is the output of the SQL query:

CUSTOMER

CUSTID NAME
4000 Mike
5000 Alice
6000 Bob
7000 Mary
8000 Ben
9000 John

ORDER

ORDERID CUSTID DATE
1 7000 2016/04/17
2 5000 2016/03/17
3 8000 2016/03/29
4 4000 2016/04/25
 
SQL > SELECT NAME FROM CUSTOMER WHERE EXISTS (SELECT * FROM ORDER
   WHERE CUSTOMER.CUSTID = ORDER.CUSTID);
7.
In SQL, a __________ returns all rows from the left-hand and right-hand tables with NULL values in places where the join condition is not met.
8.

What is the output of the following SQL query:



 
 
SELECT SUBSTRING_INDEX("www.abc.com", ".", 1);
9.

Based on the following table, what does the SQL query do:

CUSTOMER

ID LNAME FNAME WEBSITE
6000 Johnson Alice Amazon
5000 Jones Bob Apple
4000 Johnson Ben Microsoft
7000 White Mike Apple
8000 Green Tara NULL
9000 Davis Lisa Amazon
 
SQL > DELETE FROM CUSTOMER WHERE LNAME = 'Johnson' OR WEBSITE = 'Apple' OR ID = 8000 OR FNAME=’Lisa’;
SQL > SELECT * FROM CUSTOMER;
10.

In an SQL Server, which of the following methods is used to preserve space on leaf pages and avoid splitting while creating indexes?