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

Lab M.sol 4

The document outlines a lab assignment for COSC-2203 focused on advanced SQL querying techniques, including the use of comparison operators and various SQL functions. Students are required to complete tasks involving queries that utilize these techniques and submit their work in a specific format. The lab aims to enhance students' skills in data retrieval and manipulation using SQL.

Uploaded by

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

Lab M.sol 4

The document outlines a lab assignment for COSC-2203 focused on advanced SQL querying techniques, including the use of comparison operators and various SQL functions. Students are required to complete tasks involving queries that utilize these techniques and submit their work in a specific format. The lab aims to enhance students' skills in data retrieval and manipulation using SQL.

Uploaded by

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

Database Systems-Lab

COSC-2203
Instructor: Syeda Isha

Student Name: MUHAMMAD NASEER

Registration Number: INFT231102014

Class/Sec: 4C
Grade

Q#1
Q#2
Q#3
Total

Notes:

● Solve the assignment individually


● You have to use this cover page when submit your solution
● Your work must be organized, comprehensible, easy to read and follow.
● Submission should be printed out, not handwritten.
● Handwritten assignments are penalized -1.
Print Screens should show an opened text editor with your name and student
id.

Lab 4: Advanced Querying Techniques


Objective:
• Understand and apply advanced SQL querying techniques.
• Learn to use comparison operators, BETWEEN/NOT BETWEEN, IN/NOT IN, LIKE/NOT LIKE,
and IS NULL/IS NOT NULL in SQL queries. Lab Duration: 3 Hours

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)

1. Open a new query window in SSMS.

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):

1. What is the difference between using BETWEEN and IN?


2. Write a query to find all products with a price that is not within the range of 20 to 100.
3. How would you search for employees whose first name contains the letters 'Mi'?

Lab Submission Requirements:

• Screenshots of SQL queries and their outputs.


• A short report explaining the steps performed.
• SQL file with the queries used.
Conclusion:

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.

You might also like