From the course: Microsoft SQL Server 2016: Query Data
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using CASE expressions - SQL Server Tutorial
From the course: Microsoft SQL Server 2016: Query Data
Using CASE expressions
- [Instructor] In this lesson, we'll take a look at case expressions and SQL server. To understand why we might want to use case expressions, we've set up a very specific scenario here. We'll take a look at this case statement in a moment, but what I want to do initially, is just simply run this query, where we're bring back the first name, last name, and a field called PersonType from our person table. Let's look at the results to get return. We see that we have the first name, we have the last name and they're perfectly readable, because they're people's names. But in the person type field, we have abbreviations, or what we can assume to be abbreviations. We've got EM, SC, VC, GC, IN. So, unless you're the person who's actually entered the data, and you truly understand what those values mean, most people looking at these results set are not going to know what EM stands for or what these abbreviations are for. So again, remember, when you're querying your data, chances are, you're…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.