SQL-SET2 NEW

SQL-SET2 NEW

Professional Development

20 Qs

quiz-placeholder

Similar activities

SQL Quiz

SQL Quiz

University

19 Qs

SQL Queries

SQL Queries

12th Grade

25 Qs

Round 1 for Preplacement Bootcamp.

Round 1 for Preplacement Bootcamp.

University

15 Qs

DML

DML

University

25 Qs

DBMS Ex 1

DBMS Ex 1

University

15 Qs

QUIZ 3 - DFC2083

QUIZ 3 - DFC2083

University

15 Qs

REVISION ON SQL

REVISION ON SQL

8th Grade

20 Qs

ERD DATABASE

ERD DATABASE

University

15 Qs

SQL-SET2 NEW

SQL-SET2 NEW

Assessment

Quiz

Computers

Professional Development

Hard

Created by

V PERUMAL

Used 10+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

There are many ways to fetch first 5 characters of the string.

In the following options, which command is used to fetch first 5 characters of the string?

1. Select SUBSTRING(StudentName,1,5) as studentname from student

2. Select RIGHT(Studentname,5) as studentname from student

option 1 only

option 2 only

both the options are correct

both the options are incorrect

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Write an SQL query to fetch the no. of workers for each department in the descending order.

SELECT DEPARTMENT, count(WORKER_ID) No_Of_ Workers FROM worker GROUP BY DEPARTMENT SORT BY No_Of_Workers DESC;

SELECT DEPARTMENT, count(DEPART_ID) No_Of_Depart,count(WORKER_ID) No_Of_Workers GROUP BY DEPARTMENT SORT BY No_Of_Workers DESC;

SELECT DEPARTMENT, count(WORKER_ID) No_Of_Workers FROM worker GROUP BY DEPARTMENT ORDER BY No_Of_Workers DESC

SELECT DEPARTMENT, count(DEPART_ID) No_Of_Depart,count(WORKER_ID) No_Of_Workers,FROM worker GROUP BY DEPARTMENT SORT BY No_Of_Workers DESC;

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Assume a schema of Emp ( Id, Name, DeptId ) , Dept ( Id, Name).

If there are 10 records in the Emp table and 5 records in the Dept table, how many rows will be displayed in the result of the following

SQL query: Select * From Emp, Dept

The query will result in 25 rows as a “cartesian product” or “cross join”

The query will result in 35 rows as a “cartesian product” or “cross join”

The query will result in 15 rows as a “cartesian product” or “cross join”

The query will result in 50 rows as a “cartesian product” or “cross join”

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Write a SQL query to find the 10th highest employee salary from an Employee table.

SELECT TOP (1) Salary FROM ( SELECT DISTINCT TOP (10) Salary FROM Employee ORDER BY Salary DESC ) AS Emp ORDER BY Salary

SELECT DISTINCT TOP (10) Salary FROM Employee ORDER BY Salary DESC AS Emp ORDER BY Salary

SELECT TOP (10) Salary FROM ( SELECT DISTINCT TOP (1) Salary FROM Employee ORDER BY Salary DESC ) AS Emp ORDER BY Salary

ELECT DISTINCT TOP (10) Salary FROM Employee ORDER BY Salary ASC AS Emp ORDER BY Salary

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How to find a duplicate records with one field?

SELECT name, COUNT(email) FROM users GROUP BY email HAVING COUNT(email) > 1

SELECT name, email, COUNT(*) FROM users GROUP BY name, email HAVING COUNT(*) >1

SELECT name, email, COUNT(*) FROM users GROUP BY name, email HAVING COUNT(*) =1

SELECT name, COUNT(email) FROM users GROUP BY email HAVING COUNT(email) < 1

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Write an SQL query to fetch all the employees who either live in California or work under a manager with ManagerId – 321.

SELECT EmpId, City, ManagerId FROM EmployeeDetails WHERE City='California' AND ManagerId='321';

SELECT EmpId, City, ManagerId FROM EmployeeDetails WHERE City=California OR ManagerId='321';

SELECT EmpId, City, ManagerId FROM EmployeeDetails WHERE City='California' OR ManagerId='321';

SELECT EmpId, City, ManagerId FROM EmployeeDetails WHERE City='California' AND ManagerId=321;

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Write an SQL query to update the employee names by removing leading and trailing spaces.

UPDATE EmployeeDetails SET FullName = RTRIM(LTRIM(FullName));

UPDATE EmployeeDetails SET FullName = LTRIM(RTRIM(FullName));

UPDATE EmployeeDetails SET FullName = RTRIM(FullName);

UPDATE EmployeeDetails SET FullName <>LTRIM(RTRIM(FullName));

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?