急: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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行