有一Table表 三个字段:cus,mat,money
cus mat money
美国 猪肉 30000
美国 牛肉 20000
日本 猪肉 4000
越南 猪肉 55000
越南 牛肉 3000
....怎么把Table表查询显示为下面这种模式啊??Cus 猪肉 牛肉
美国 30000 20000
日本 4000 0
越南 55000 3000
....大虾们,求助了....
cus mat money
美国 猪肉 30000
美国 牛肉 20000
日本 猪肉 4000
越南 猪肉 55000
越南 牛肉 3000
....怎么把Table表查询显示为下面这种模式啊??Cus 猪肉 牛肉
美国 30000 20000
日本 4000 0
越南 55000 3000
....大虾们,求助了....
解决方案 »
- VB处理字符是unicode编码吧,可是为何设置字体时,中文只有gb2312呀.
- 如何截获在“我的电脑”里对文件的复制、粘贴、删除操作呢?
- 关于鼠标中键事件???????????
- 怎样动态的生成sql语句
- access数据库新添加的数据vb中读不到,请指教!
- 救命呀!我实在搞不定了!(1)
- 兄弟们,救救我吧
- 请教如何用SendMessage向窗体发送键盘信息,比如我想发送一个组合键:ctrl+x,请教如何进行?
- 在VB中如何得到程序当前路径?!马上送分!!!^-^
- 如何控制excel使之不可被关闭(不能在 objexc_WorkbookBeforeClose中做文章)
- 关于LISTVIEW列的问题
- 100分答谢:WINSOCK客户端组包问题
ACCESS用iif
楼上,能否给多点提示啊??
好人做到底,给个完整点的答案,行不?
谢谢了
select cus,
sum(case when mat='猪肉' then money else 0) as '猪肉',
sum(case when mat='牛肉' then money else 0) as '牛肉'
from tb
group by cus试试吧,随手写的
select cus,
sum(case when mat='猪肉' then money else 0 end) as '猪肉',
sum(case when mat='牛肉' then money else 0 end) as '牛肉'
from tb
group by cus
n=rs.recordcountmsflexgrid1.FormatString="< |^ cus |^ 猪肉|^牛肉"
msflexgrid1.rows=n+1
msflexgrid1.cols=4rs.movefirst
for i=1 to n+1
msflexgrid1.TextMatrix(i, 1)=rs!cus '国家 rs1.open "select * from 表1 where cus='"& msflexgrid1.textmatrix(i,1) &"'" and mat='猪肉'",db, adOpenDynamic, adLockOptimistic rs2.open "select * from 表1 where cus='"& msflexgrid1.textmatrix(i,1) &"'" and mat='牛肉'",db, adOpenDynamic, adLockOptimistic msflexgrid1.TextMatrix(i, 2)=rs!money '猪肉价格
msflexgrid1.TextMatrix(i, 3)=rs!money '牛肉价格 rs.movenext
next