| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 973 人关注过本帖
标题:急需帮助,一条极其挑战的查询
只看楼主 加入收藏
tangyunzhong
Rank: 5Rank: 5
来 自:广西
等 级:职业侠客
威 望:4
帖 子:97
专家分:364
注 册:2010-7-28
收藏
得分:4 
我是以你的前面描述的写出来的语句如下:
select [datetime],(case a when 'a' then sum_a_num else 0 end) as sum_a_num,
                  (case a when 'b' then sum_a_num else 0 end) as sum_b_num,
                  (case a when 'd' then sum_a_num else 0 end) as sum_c_num
from (
select adate as [datetime],a,sum(anum) as sum_a_num
from (
select *,'a' as a from a  
union all
select *,'b' as b from b
union all
select *,'d' as d from d
) m
group by a,adate
) n

[ 本帖最后由 tangyunzhong 于 2010-10-30 21:02 编辑 ]
2010-10-30 21:01
ivantse
Rank: 1
等 级:等待验证会员
帖 子:16
专家分:0
注 册:2010-10-18
收藏
得分:0 
回复 6楼 tangyunzhong
sum_c_num列我弄错了,我之前的描述出来错误,现在该过来了,你再看看!
2010-10-30 21:04
快速回复:急需帮助,一条极其挑战的查询
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014857 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved