IT2003
Laboratory Exercise
T-SQL Conditional Statements
Objectives:
At the end of the exercise, the students should be able to:
Apply various conditional statements
Software Requirement:
Microsoft SQL Server Management Studio 18.0 or higher
Microsoft SQL Server Express 2017
Procedures:
1. Create a database named LabDB and create a table named Records and put the following data. See
the screenshot below.
2. Fetch each data from table Records using a while loop and evaluate them using IF-ELSE AND CASE
statements. If the returning age is 14 to 16, change the level to Freshman. If 17 to 19, change it to
Sophomore. If 20 to 22, change it to Junior. Lastly, if 23 to 25, change it to Senior. If the returning
age is not in the given range, change their level to 'Unknown'.
3. Querying data through IF-ELSE statement should display their level to LOWERCASE. Else, using the
CASE statement should display their level to UPPERCASE.
4. Display the updated level of each data using a PRINT statement. See the sample output on the next
page.
01 Laboratory Exercise 1 *Property of STI
Page 1 of 3
IT2003
Sample Output for IF-ELSE statement:
Sample Output for CASE statement:
01 Laboratory Exercise 1 *Property of STI
Page 2 of 3
IT2003
GRADING RUBRIC:
CRITERIA PERFORMANCE INDICATORS POINTS
Correctness The code produces the expected result. 30
Logic The code meets the specifications of the problem. 30
Efficiency The code is concise without sacrificing correctness and logic. 20
Syntax The code adheres to the rules of the databasemanagement system. 20
Total 100
01 Laboratory Exercise 1 *Property of STI
Page 3 of 3