0% found this document useful (0 votes)
2K views3 pages

T-SQL Conditional Statements Exercise

This document provides objectives, requirements, and procedures for a laboratory exercise on using conditional statements in T-SQL. Students will create a database and table to store sample student data. They will then write code to fetch the data and evaluate each record's age field using IF-ELSE and CASE statements to update a level field, handling different age ranges as Freshman, Sophomore, etc. or 'Unknown'. The output will display the updated levels in different cases. Students will be graded based on correctness, logic, efficiency, and syntax of their code.

Uploaded by

Ruq Baldemor
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)
2K views3 pages

T-SQL Conditional Statements Exercise

This document provides objectives, requirements, and procedures for a laboratory exercise on using conditional statements in T-SQL. Students will create a database and table to store sample student data. They will then write code to fetch the data and evaluate each record's age field using IF-ELSE and CASE statements to update a level field, handling different age ranges as Freshman, Sophomore, etc. or 'Unknown'. The output will display the updated levels in different cases. Students will be graded based on correctness, logic, efficiency, and syntax of their code.

Uploaded by

Ruq Baldemor
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
  • Laboratory Exercise Overview

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

You might also like