0% found this document useful (0 votes)
16 views

SQL Assessment

The document provides examples of SQL queries to retrieve data from database tables using different clauses and operators. It shows how to select columns, limit rows, filter rows based on conditions, find missing or non-null values, and retrieve unique values using clauses like SELECT, FROM, WHERE, LIMIT, OFFSET, DISTINCT and operators like IN, NOT IN, LIKE, IS NULL, IS NOT NULL.

Uploaded by

shrutisuman03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

SQL Assessment

The document provides examples of SQL queries to retrieve data from database tables using different clauses and operators. It shows how to select columns, limit rows, filter rows based on conditions, find missing or non-null values, and retrieve unique values using clauses like SELECT, FROM, WHERE, LIMIT, OFFSET, DISTINCT and operators like IN, NOT IN, LIKE, IS NULL, IS NOT NULL.

Uploaded by

shrutisuman03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

How do you display the values in the "first_name" column of the "employees"

table in SQL?

-> select first_name from employees;

2. How do you display all the columns and their respective values from the

"employees" table in SQL?

-> select * from employees;

3. How do you retrieve only 5 rows of data from the "employees" table in SQL?

[Hint: using limit]

-> select * from employees limit 5;

4. How do you select the employee with the name "Danny Devgan" from the

"employees" table in SQL? [Hint: using where clause]

-> select * from employees where employee_id=6;

5. How do you retrieve the employee with employee ID "37" from the

"employees" table (by starting at offset 36 and limiting the result to 1 row) in

SQL? [Hint: using limit, offset]

-> select * from employees limit 1 offset 36;

6. How do you select the employees from the "employees" table who have an

employee ID ranging from 33 to 38 inclusive in SQL? [Hint: using in operator]

-> select * from employees where employee_id IN (33,34,35,36,37,38);


7. How do you use the WHERE clause to filter the "department_name" column in

the "employees" table to only show values of "IT" and "Construction" in

SQL?

-> select * from departments where department_id IN (11,23);

8. How do you use the WHERE clause to filter the "department_name" column in

the "employees" table to only show values that are not "IT" and

"Construction" in SQL?

-> select * from departments where department_id NOT IN (11,23);

9. How do you identify missing "manager_id" values in the "departments" table

in SQL?

-> select * from departments where manager_id IS null;

10. How do you retrieve only the non-NULL values of the "manager_id" column

from the "departments" table in SQL?

-> select * from departments where manager_id IS NOT null;

11. How do you retrieve the values of the "first_name" column in the "employees"

table that start with "sh" in SQL?

-> select * from employees where first_name LIKE "Sh%";

12. How do you select only last_name those ending with "ra" in SQL?

-> select * from employees where last_name LIKE "%ra";


13. How do you retrieve the values of the "last_name" column in the "employees"

table that end with "ra" in SQL?

-> select last_name from employees where last_name LIKE "%ra";

14. How do you retrieve the information of the employee in the "employees" table

whose "first_name" starts with "sa" and ends with "a" in SQL?

-> select * from employees where first_name LIKE "Sa%" AND last_name LIKE "%a";

15. How do you retrieve information of employees from the "employees" table

that do not have "sharma" as their "last_name" in SQL?

-> select * from employees where last_name NOT LIKE "sharma";

16. How do you retrieve the unique values of the "last_name" column in the

"employees" table in SQL

-> select distinct last_name from employees;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy