From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Challenge: Create a function

Challenge: Create a function

We've spent some time exploring functions, and I'd like to challenge you to write one on your own. In the Wide World Importers database in the Warehouse.ColdRoomTemperatures table, we have some temperature measurements. I'd like you to create a function that evaluates these temperatures and returns a text description. If the temperature is less than 3.5 degrees, the function should return the text "too cold." If the temperature is above four degrees, then it should return the text "too hot." And if the temperature is within the range of 3.5 to 4, then the function should return "just right." See if you can create the function to evaluate a single number that you pass in as a parameter. Then apply that function to analyze the values stored in the ColdRoomTemperatures table. I estimate that this challenge should take about 10 minutes to complete. In the next movie, I'll walk through the process that I would take to arrive at a solution. Good luck.

Contents