#title 조건모델 작성 중.. 정리될 때까지 방문자들은 보지 말것!! attachment:조건모델/conditional_model01.jpg {{{ ;with 조건(조건번호, 이벤트, 조건, 연산자, 변수, 단위) as ( select 1, '오픈이벤트', '게임판수', '>=', '10', '판' union all select 2, '오픈이벤트', '플레이타임', '>=', '60', '분' union all select 3, '오픈이벤트', '딴돈', '>=', '1', '조' ), 조건묶음(묶음번호, 연산자, 우선순위) as ( select 1, 'or', 1 union all select 2, '', 2 ), 세부조건묶음(묶음번호, 조건번호, 연결묶음번호) as ( select 1, 1, null union all select 1, 2, null union all select 2, 3, 1 ), 묶음관계(이벤트, 묶음번호, 엮인묶음번호, 연산자) as ( select '오픈이벤트', 1, 2, 'and' ) select isnull(b.이벤트, c.이벤트) , replace(ods.dbo.string_sum(a.조건), ',', ' and ') from ( select c.묶음번호 , '(' + replace(ods.dbo.string_sum(a.조건 + a.연산자 + 변수 + '[' + 단위 + ']'), ',', ' ' + c.연산자 + ' ') + ')' 조건 from 조건 a inner join 세부조건묶음 b on a.조건번호 = b.조건번호 inner join 조건묶음 c on b.묶음번호 = c.묶음번호 group by c.묶음번호 , c.연산자 ) a left join 묶음관계 b on a.묶음번호 = b.묶음번호 left join 묶음관계 c on a.묶음번호 = c.엮인묶음번호 group by isnull(b.이벤트, c.이벤트) }}} 그냥 조건을 구구절절 표현하기보다는 호출할 프로시저나 함수, 스크립트를 집어 넣는게 더 빠르것다. ---- 벌써 봤는데요... -- 방문자 2011-06-02 18:03:20 ---- 나도 봤는데 ~ 뭔지 모르겠당 ㅋㅋ -- 11 2011-06-03 13:25:28