我有一个包含以下数据的表
<?php
interface ISanitizedValue {
public function value();
}
class CSanitizedLogin implements ISanitizedValue {
private $_rawValue;
public function __construct($value){
$this->_rawValue = $value;
}
public function value(){
// sanitizing
}
}
class CSomeClass {
// force to use ISanitizedValue
public function __construct(ISanitizedValue $login){}
}
$login = new CSanitizedLogin($_GET['login']);
$example1 = new CSomeClass($login);
$example2 = new CSomeClass($login);
?>
我希望将其转换为如下表所示
SKU Site Code Value
0890 50 BRAND OMH
0890 50 CSBC 0763440890
0890 50 DWPS 0763440890
0890 50 DWS 0763440890
0890 50 DWSG *
0890 50 EA 1
我们拥有的Oracle数据库版本是10G,所以PIVOT还没用。
请帮忙。
答案 0 :(得分:2)
Oracle 10没有数据透视表,因此您可以使用条件聚合:
select sku,
max(case when code = 'BRAND' then value end) as brand,
max(case when code = 'CSBC' then value end) as CSBC,
max(case when code = 'DWPS' then value end) as DWPS,
max(case when code = 'DWS' then value end) as DWS,
max(case when code = 'DWSG' then value end) as DWSG,
max(case when code = 'EA' then value end) as ea
from t
group by sku;