请问一条SQL语句,先谢谢了!!!!!!

Bardo 2002-03-05 01:48:50
原表
A,B,C,
1,1,2
2,1,3
3,1,4
4,2,3
5,2,4
6,3,5
7,3,6

集果记录集:
A,B,C1,C2,C3,C4
1,1,2, 0, 0, 0
2,1,3, 0, 0, 0
3,1,4, 0, 0, 0
4,2,0, 3, 0, 0
5,2,0, 4, 0, 0
6,3,0, 0, 5, 0
7,3,0, 0, 6, 0
...全文
61 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
TechnoFantasy 2002-03-05
  • 打赏
  • 举报
回复
高手,学了一招。
Bardo 2002-03-05
  • 打赏
  • 举报
回复
楼上的两位高手都对!马上结帐!!!!
Yang_ 2002-03-05
  • 打赏
  • 举报
回复
select A,B,(case b when 1 then c else 0 end) as c1,
(case b when 2 then c else 0 end) as c2,
(case b when 3 then c else 0 end) as c3,
(case b when 4 then c else 0 end) as c4
from tablename
Yang_ 2002-03-05
  • 打赏
  • 举报
回复
select A,B,(case b when 1 then c else 0 end) as c1,
(case b when 2 then c else 0 end) as c2,
(case b when 3 then c else 0 end) as c3
from tablename
warning 2002-03-05
  • 打赏
  • 举报
回复
select A,B,(case when b=1 then c else 0 end) c1,
(case when b=2 then c else 0 end) c2,
(case when b=3 then c else 0 end) c3
from tablename
Bardo 2002-03-05
  • 打赏
  • 举报
回复
注意B是己知的
是可以实现的,关键我对Case用法不熟!
TechnoFantasy 2002-03-05
  • 打赏
  • 举报
回复
这个完全用sql语句无法解决,需要自己写一些代码来实现。

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧