解决方案 »
- 确认下:是不是真的没有查询表被访问的次数的方法
- oracle 10g 的OCI目录下 找不到samples目录
- 怎样在sql*plus里写SQL对数据库做备份和恢复? 我要实现的是用程序代码控制oracle的备份和恢复请指点一二??
- 求教:ORACLE多表联合查询的高效方法
- 如何将excel(csv或xls格式)的数据导入到oracle数据库中
- 求SQL(表A, 字段1为d1,字段2为d2.求SQL语句,功能要求:当d2为空时,用常量5跟d1比大,当d2不为空时5跟d2比大的所有记录)
- 数据库备份与恢复的问题
- 索引中丢失in或out参数……是什么意思?在线等待!
- 怎么让这个时间变化,为当前时间!!!!
- 为什么我的98机子,装oracle 客户端,sql plus 连接不通??????? 急!!(我的 net8 configurration assistant 测试是成功的)
- 请教大家一个关于在64位环境下运行32位Oracle客户端的问题
- 连接查询
SQL> with tablea as (
2 select 'A0101' product_id, 1 property_id,'颜色' property_name, '红' property_values from dual union all
3 select 'A0101' product_id, 2 property_id,'款式' property_name, '大号' property_values from dual union all
4 select 'A0101' product_id, 3 property_id,'长度' property_name, '10' property_values from dual union all
5 select 'A0102' product_id, 1 property_id,'长度' property_name, '20' property_values from dual
6 )
7 select product_id,
8 max(decode(property_name, '颜色', property_values)),
9 max(decode(property_name, '款式', property_values)),
10 max(decode(property_name, '长度', property_values))
11 from tablea
12 group by product_id order by product_id
13 /PRODUCT_ID MAX(DECODE(PROPERTY_NAME,'颜色 MAX(DECODE(PROPERTY_NAME,'款式 MAX(DECODE(PROPERTY_NAME,'长度
---------- ------------------------------ ------------------------------ ------------------------------
A0101 红 大号 10
A0102 20SQL>
视图:v_
存储过程:p_
触发器:tr_
主键:pk_
外键:fk_
索引:ix_
局部变量:v_
入口参数:i_
...
SQL> with tablea as (
2 select 'A0101' product_id, 1 property_id,'颜色' property_name, '红' property_values from dual union all
3 select 'A0101' product_id, 2 property_id,'款式' property_name, '大号' property_values from dual union all
4 select 'A0101' product_id, 3 property_id,'长度' property_name, '10' property_values from dual union all
5 select 'A0102' product_id, 1 property_id,'长度' property_name, '20' property_values from dual
6 )
7 select product_id,
8 max(decode(property_name, '颜色', property_values)),
9 max(decode(property_name, '款式', property_values)),
10 max(decode(property_name, '长度', property_values))
11 from tablea
12 group by product_id order by product_id
13 /这个不错……
A0101 1 颜色 红
A0101 2 款式 大号
A0101 3 长度 10
A0102 1 长度 20
结果表:
product_id 颜色 款式 长度
A0101 红 大号 10
A0102 20===>
select product_id,
max(case property_name when '颜色' then property_values) as 颜色,
max(case property_name when '款式' then property_values) as 款式,
max(case property_name when '长度' then property_values) as 长度
from tb
group by product_id
order by product_id ;