设为首页
收藏本站
开启辅助访问
切换到窄版
登录
立即注册
中问网首页
我的收藏
站长博客
搜索
搜索
本版
帖子
用户
第一问答网
»
论坛
›
中问网
›
问答
›
急:sql 结果合并问题
返回列表
发新帖
急:sql 结果合并问题
[复制链接]
11
|
2
|
2010-1-19 08:00:16
|
显示全部楼层
|
阅读模式
select 时间,温度 from 库表 where 站号 in(549,557,558); sql查询一般只能按一个字段名作为索引,你要按两个字段(时间、温度)是不行的你要排序清楚,可以在后面加上 order by 时间/温度 你这不就是按两个字段索引么。。 - -#
回复
使用道具
举报
千问
|
2010-1-19 08:00:16
|
显示全部楼层
感谢2楼的参考答案,我给出的是case when的实现方式,其他的方式请提问者自己研究一下。create table 库表(站号 int, 时间 varchar2(500),温度 int);select * from 库表 for update;
站号 时间 温度1 549 0001 262 557 0001 273 558 0001 354 549 0002 215 558 0002 236 557 0002 27select 时间, sum(case when 站号=549 then 温度 end) as "549温度", sum(case when 站号=557 then 温度 end) as "557温度", sum(case when 站号=558 then 温度 end) as "558温度" from 库表 group by 时间; 时间 549温度 557温度 558温度1 0001 26 27 352 0002 21 27 23
回复
使用道具
举报
千问
|
2010-1-19 08:00:16
|
显示全部楼层
select时间, decode ( 站号 ,549,温度 ) ,decode ( 站号 ,557,温度) , decode ( 站号 ,558,温度) from biao
回复
使用道具
举报
返回列表
发新帖
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
千问
主题
0
回帖
4882万
积分
论坛元老
论坛元老, 积分 48824836, 距离下一级还需 -38824837 积分
论坛元老, 积分 48824836, 距离下一级还需 -38824837 积分
积分
48824836
加好友
发消息
回复楼主
返回列表
问答
热门排行