譴..
襴 蟾讌 覦覓語れ 覲伎 襷蟆!!

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.企欧)

蠏碁 譟郁唄 蟲蟲 蠍磯慨る 語 襦 , ろ襴渚碁ゼ 讌 k蟆 觜襯願.


覯 覺る一... -- 覦覓語 2011-06-02 18:03:20

覺る ~ 覘讌 覈襯願 -- 11 2011-06-03 13:25:28