Lab M.sol 4
Lab M.sol 4
COSC-2203
Instructor: Syeda Isha
Class/Sec: 4C
Grade
Q#1
Q#2
Q#3
Total
Notes:
Pre-requisites:
• SQL Server and SSMS installed.
• Basic understanding of databases and the purpose of tables.
Theory Overview:
SQL provides powerful operators and keywords that allow users to filter and manipulate data in
more advanced ways. These advanced techniques include:
• Comparison Operators: Used to compare two expressions and return boolean values.
• BETWEEN/NOT BETWEEN: Used to filter data within a specific range.
• IN/NOT IN: Used to check if a value matches any value in a list.
• LIKE/NOT LIKE: Used to search for patterns in text fields. IS NULL/IS NOT
NULL: Used to check for NULL values.
Tasks:
Task 1: Search with Comparison Operators (30 Minutes)
2. Write and execute the following query to find all employees with a salary greater than 40000:
3. Write and execute the following query to find employees whose salary is between 30000 and
50000:
4. Verify the results for each query.
Task 2: Use of BETWEEN/NOT BETWEEN (30 Minutes)
Task 3: Use of IN/NOT IN (30 Minutes)
Task 4: Use of LIKE/NOT LIKE (30 Minutes)
Task 5: Use of IS NULL/IS NOT NULL (30 Minutes)
1. Write and execute the query to find employees whose DateOfBirth is NULL:
2. Verify the results for each query.
Lab Questions (Assignment Tasks):
In this lab, students learned how to use advanced SQL querying techniques
including comparison
operators, BETWEEN/NOT BETWEEN, IN/NOT IN, LIKE/NOT LIKE, and IS NULL/IS NOT NULL.
These techniques are essential for more precise data retrieval and allow you to filter data in
complex ways based on multiple conditions.