oracle列转行问题 - Oracle / 基础和管理
现在一个表中有两列数据
shuliang area
1 025
2 0510
3 0511
4 0512
5 0513
要求是把area字段中的值转换成城市名称,比如025是南京,0510是无锡,0511是镇江,0512是苏州,0512是南通
显示成
南京 无锡 镇江 苏州 南通
1 2 3 4 5
请问sql怎么写啊
SQL code:
select sum(case when area = '025' then shuliang else 0 end) as 南京
,sum(case when area = '0510' then shuliang else 0 end) as 无锡
,sum(case when area = '0511' then shuliang else 0 end) as 镇江
,sum(case when area = '0512' then shuliang else 0 end) as 苏州
,sum(case when area = '0513' then shuliang else 0 end) as 南通
from 表名;
select
case when area='025' then shuliang end 南京,
case when area='0510' then shuliang end 无锡,
case when area='0511' then shuliang end 镇江,
case when area='0512' then shuliang end 苏州,
case when area='0513' then shuliang end 南通
from 表;
select sum(decode(area, '025', 1, 0)) as 南京,
sum(decode(area, '0510', 1, 0)) as 无锡,
sum(decode(area, '0511', 1, 0)) as 镇江,
sum(decode(area, '0512', 1, 0)) as 苏州,
sum(decode(area, '0513', 1, 0)) as 南通
from t
group by area
相关问答:
谢谢唐人老大的指点,谢谢各位高手的指点!
安装10g Enterprise。上网下了MLDN的Oracle视频,跟着视频上的配置走,安装成功了,但是没完整地配置。
点击进入:Database Configuration Assistant
1. 创建数据库;
......
SQL code:
CREATE OR REPLACE PROCEDURE usp_refreshTopN IS
BEGIN
--文档
INSERT INTO topnresource(resourceId,title,type,cover,brief,properUser,tag,clickAmount,createDate,topNCreateDate,organizat ......
今天遇到一个很诡异的问题。我在一张表中新增了一个字段。然后用如下脚本更新这个字段的值:
SQL code:
update ibp_fund_information_tab set yield = 7.4520 where fund_code = '040003' and info_date = ......
java.sql.SQLException: ORA-04031: unable to allocate 26416 bytes of shared memory ("shared pool","SELECT * from ( SELECT rownu...","Typecheck heap","qry_text : qcpis ......