From the course: SQL Server Intelligence: Cracking the Code of Enterprise Data

Unlock the full course today

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

The CASE statement

The CASE statement

- [Instructor] So now, let's add a little twist to our case statement. What if we had a marketing initiative to now target one segment or one bucket that we have now defined? So let's say we are now targeting our minors and going to introduce some sort of ad campaign to this segment. How would we now filter our 126 rows down to just the minors? So when we speak of filtering, we know we have to introduce our where clause. And we want to say where the result of this case statement, and I'm just going to grab from the case all the way to the end and I'm going to ignore the alias. As we know, when we are trying to filter down our records, we are not going to use the alias in our where clause, but the actual calculation if it's a calculated column. In this case, the actual case statement as it's a case statement. So let's now grab this case statement. And I'm going to go into the where clause and just drop that case…

Contents