김홍철 2013.08.30 13:02 Views : 4167
tinyint인 필드들의 or연산된 값들을 구하는 함수가 있는지요?
sum처럼 전체 레코드들을 or 연산 (bit연산) 하고 싶은데
지원하는 함수가 없다면 구할 수 있는 방법이 어떤게 있을까요/
2013.08.30 13:51
따로 전체를 합하는 개념은 없고 만드셔야 할듯...
or연산은 --> |
and연산 --> &
declare @bitor integer set @bitor = 0 ;with res as ( select 1 no union all -- 0001 select 2 no union all -- 0010 select 3 no union all -- 0011 select 4 no union all -- 0100 select 5 no union all -- 0101 select 6 no ) -- 0110 select @bitor = @bitor | no from res select @bitor -- 7( 0111)
cmd_comment_vote_user Upvote0 Downvote0
2013.08.30 16:03
변수 하나 만들고 select 하면 전체 or연산이 되는군요...
감사합니다...
2013.08.30 16:11
대신 and일때는 초기값이 15(1111)이 되어야 하겠구요.. 물론 숫자의 크기에 따라 달라질거구요....
Keep me signed in.
따로 전체를 합하는 개념은 없고 만드셔야 할듯...
or연산은 --> |
and연산 --> &
declare @bitor integer
set @bitor = 0
;with res as
(
select 1 no union all -- 0001
select 2 no union all -- 0010
select 3 no union all -- 0011
select 4 no union all -- 0100
select 5 no union all -- 0101
select 6 no ) -- 0110
select @bitor = @bitor | no
from res
select @bitor -- 7( 0111)