Board logo

標題: 求助 excel vba 查找 sql table 欄位內包含字段 [打印本頁]

作者: sammyc    時間: 2011-5-23 17:30     標題: 求助 excel vba 查找 sql table 欄位內包含字段

本帖最後由 sammyc 於 2011-5-23 17:45 編輯

在vba 內 連到sql 的數據
需將gxmc 內包括",1," 的字串篩選填入t_01內, 但一直篩選不到
sql 語句
select zdh, gxmc ,
case gxmc  when  '%,1,' then sum(shul)
when  ',1,' then sum(shul)
when  ',1,%' then sum(shul)
when  '%,1,%' then sum(shul)
        end "T_01" ,
        case gxmc  when ',2,' then sum(shul) end "T_02"
from jjgzmxb
where zdh ='12330-01a'
group by zdh, gxmc

jjgzmxb資料
zdh                              gxmc                         T_01        T_02
12330-01A        ,1,14,15,36,               
12330-01A        ,12,10,               
12330-01A        ,13,
12330-01A        ,1,                               14256       
12330-01A        ,1,2,               
12330-01A        ,1,20,               
12330-01A        ,2,                                                  4157
12330-01A        ,10,11,               
12330-01A        ,10,11,19,               
12330-01A        ,10,15,               
12330-01A        ,11,




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)