-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_01.sql
31 lines (26 loc) · 865 Bytes
/
04_01.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- FILE: 04_01.sql
-- Video: Case statements
---------------------------------------------------------------------------------------------------------
use sandbox; -- to update the Database Name in this Query file or notebook.
declare @number int
select
divisible = case
when @number % 2 = 0
then 'divisible by 2'
when @number % 3 = 0
then 'divisible by 3'
else 'does not meet the criteria'
end
---------------------------------------------------------------------------------------------------------
-- add the concept to variable, scalar Variable
-- Playing with the int value
-- WHEN CASE , Statement
declare @number int = 5867 -- ( Change here the value or number adn run it)
select
divisible = case
when @number % 2 = 0
then 'divisible by 2'
when @number % 3 = 0
then 'divisible by 3'
else 'does not meet the criteria'
end