_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › 貎朱Μ襯殊伎BETWEENJOIN豕
|
|
譴..
[edit]
1 螳 #れ螻 螳 between join 貎朱Μ螳 り .
select b.value_code , count(a.cust_key) from tableA a inner join tableB b on a.val between b.begin_value and b.end_value when @dt between appl_begin_dt and appl_end_dt group by b.value_code tableA 3豌 襷 蟇伎願, tableB 20蟇伎企. DB between join 覯 譬蟇 蟇 nested loop join 願鍵 覓語 豌伎 豌襴螳 蟾讌 襷 螳 襦 . 企 蟆曙 貎朱Μ襯 伎覃 豕 . 螳企慨覃 覲 蟆 .
[edit]
2 #declare @bdt char(8) , @edt char(8) , @sql varchar(8000) , @col varchar(255) set @bdt = '20101102' set @edt = '20101103' set @sql = '' set @col = 'val' select @sql = @sql + 'when ' + @col + ' between ' + convert(varchar(60), begin_value) + ' and ' + convert(varchar(60), end_value) + ' then ''' + value_code + '''' + char(13)+char(10) from tableB where @bdt between appl_begin_dt and appl_end_dt set @sql = 'case ' + @sql + ' end' set @sql = ' select ' + @sql + ' value_code , count(distinct cust_key) from tableA where 1=1 and regdate >=' + quotename(@bdt, '''') + ' and regdate < ' + quotename(@edt, '''') + ' group by ' + @sql print @sql exec (@sql) れ襦 れ螻 螳 覓語レ朱 ろ 蟆企. between join 蟆覲企 譟磯 觜襯伎 蟆?
select case when umoney between 0 and 499999 then '8炎' when val between 500000 and 4999999 then '7炎' when val between 5000000 and 49999999 then '6炎' when val between 50000000 and 499999999 then '5炎' when val between 500000000 and 4999999999 then '4炎' when val between 5000000000 and 49999999999 then '3炎' when val between 50000000000 and 499999999999 then '2炎' when val between 500000000000 and 9223372036854775807 then '1炎' end value_code , count(distinct cust_key) from tableA where 1=1 and a.regdate >='20101102' and a.regdate < '20101103' group by case when umoney between 0 and 499999 then '8炎' when val between 500000 and 4999999 then '7炎' when val between 5000000 and 49999999 then '6炎' when val between 50000000 and 499999999 then '5炎' when val between 500000000 and 4999999999 then '4炎' when val between 5000000000 and 49999999999 then '3炎' when val between 50000000000 and 499999999999 then '2炎' when val between 500000000000 and 9223372036854775807 then '1炎' end
鏤
|
苦 蟾 危危覃 襦 譯曙 蠏碁 譴企. (ろ) |