根据标准化值

时间:2017-11-21 23:24:11

标签: sql database oracle plsql

enter image description here有点粗鲁的问题。如果所有值都标准化,是否可以根据每列中的值选择10列。

所以例如

cluster Id | v1 | v2| v3 | v4 | v6 | v26 
___________________________________________
       1   | 4.2|0.9|05  |3.2 | 0.7|0.5
       2   | 1.2|0.1|0.9 |0.21|0.3 |0.1

所以在这个例子中,如果我想要群集1的3个前三列,我就有

     cluster ID |v1 |v4 |v2
            1   |4.2|3.2|0.9

我现在对使用Oracle Sql的任何建议持开放态度,但如果在不同平台上使用解决方案并且使用SQL无法实现此解决方案,那么请求切换

修改。我添加了一个图像,显示我正在尝试在Sql开发人员上复制的功能。获取大小是变量/属性的数量,并且当我更改获取大小时,必须有一些表位于要查询的模型后面,那就是我正在尝试重现的语句 谢谢

2 个答案:

答案 0 :(得分:2)

如果你想要前三个值,我会忽略数据并重新聚合。 Oracle 12c具有一些有用的功能;对于早期版本,我只会使用更传统的SQL方法。

目前还不清楚您是否需要列名称或值。以下两者都是:

select id,
       max(case when seqnum = 1 then v end) as v_1,
       max(case when seqnum = 2 then v end) as v_2,
       max(case when seqnum = 3 then v end) as v_3,
       max(case when seqnum = 1 then which end) as which_1,
       max(case when seqnum = 2 then which end) as which_2,
       max(case when seqnum = 3 then which end) as which_3
from (select id, v, which, row_number() over (partition by id order by v desc) as seqnum
      from ((select id, v1 as v, 'v1' as which from t) union all
            (select id, v2 as v, 'v2' as which from t) union all
            (select id, v3 as v, 'v3' as which from t) union all
            (select id, v4 as v, 'v4' as which from t) union all
            (select id, v5 as v, 'v5' as which from t)
           ) t
      ) t
group by id;

答案 1 :(得分:0)

最后,我采用的方法是遍历在数据集聚类期间创建的所有Oracle Data Miner表。其中一个表DM $ PTCLUS_K_M_1_2包含一个包含所有簇,值,变量Id和名称的数据透视表。使用我的例子在这里重新创建

cluster_id,variable_id,value,variable_name
   1      |  1        | 4.2 | v1

通过使用where子句(cluster_id)执行嵌套的select语句并按值排序,我可以选择前10个变量及其每个簇的值

select * from 
 (select * from DM$PTCLUS_K_M_1_2
     where cluster_id = 1
     order by value)
  where rownum < 11

对于那些有类似问题且希望获得集群质心或值的人,我建议查看数据表模式并检查那里的表,其中一些将包含您需要的数据