0

My table is as per below. In this example trc column contains all the possible values.

trc ([int]) sund_r([varchar]) ref_man([varchar])
0 abc1 A1355
1 abc2 A3564
2 abc1 A1975
5 abc3 A1118
7 abc3 A1011
8 abc4 A6721
10 abc2 A7723
11 abc1 A6529
12 abc4 A6084
14 abc3 A3001
15 abc2 A2088

I'm trying to understand what exactly "&" is doing in this statement:

SELECT CASE
WHEN trc&4 = 4 THEN 'S' ELSE '' END 
+ CASE
WHEN trc&8 = 8 THEN 'C' ELSE '' END 
+ CASE
WHEN trc&2 = 2 THEN 'P' ELSE '' END 
+ CASE
WHEN trc&1 = 1 THEN 'V' ELSE '' END AS trc_exp,
sund_r, ref_man
FROM table1;

Any insight would be very appreciated.

Thanks

Zandood
  • 1
  • 1
  • It's a [& (Bitwise AND) (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/bitwise-and-transact-sql?view=sql-server-ver15) – Larnu Sep 23 '21 at 09:33

0 Answers0