From the course: Program Databases with Transact-SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Create a function

Solution: Create a function - SQL Server Tutorial

From the course: Program Databases with Transact-SQL

Start my 1-month free trial

Solution: Create a function

(upbeat music) - [Instructor] I hope you were able to write out a function that took a look at temperature data inside of the Wide World Importers database. So let's walk through the solution together. I've just gone ahead and opened up a new query window and put in some comments here at the top to remind ourselves what it is that we're trying to do here. We're going to create a function that analyzes temperatures and the conditions that we placed on this is that we wanted to evaluate temperature values and if the temperature was less than 3.5, we want it to say too cold. If it's above four, we'll say too hot and everything else is just right. So let's take a look at the data that we want to work with first. And we were working with the warehouse.ColdRoomTemperatures data. So let's just see what's in there first. So I select everything out of the warehouse.ColdRoomTemperatures table, and it looks like there's four rows right now. And we have some temperature values that span that…

Contents