Oracle PL/SQL选择向量的最小值
我有一张这样的桌子:Oracle PL/SQL选择向量的最小值,oracle,plsql,Oracle,Plsql,我有一张这样的桌子: CREATE OR REPLACE TYPE tip_orase AS VARRAY(10) of VARCHAR2(50) / CREATE table excursie_try ( cod_excursie NUMBER(4), denumire VARCHAR2(20), orase tip_orase, status varchar2(20) ); 我需要找出在orase中条目数最少的条目的“cod_漂移” 我可以通过计算每个条目的城市数量并选择一个最小值
CREATE OR REPLACE TYPE tip_orase AS VARRAY(10) of VARCHAR2(50)
/
CREATE table excursie_try (
cod_excursie NUMBER(4),
denumire VARCHAR2(20),
orase tip_orase,
status varchar2(20)
);
我需要找出在orase中条目数最少的条目的“cod_漂移”
我可以通过计算每个条目的城市数量并选择一个最小值来完成大量工作。然后进行查询,给出orase中条目数最少的条目的“cod_漂移”
有没有更简单的方法?我试过这样的方法:
select cod_excursie
from excursie_try, (select max(orase.count()) m
from excursie_try) T
where orase.count = T.m
and ROWNUM <= 1;
但它不起作用。有什么想法或者我必须走很长的路吗?试试这个:
select cod_excursie from (
select et.cod_excursie,
(select count(*) from table(et.orase)) n
from excursie_try et order by 2 desc
) where rownum = 1;
orase是一个单行子查询,我在varray上使用该表模拟sql表
在子查询+中按2 desc排序,其中rownum=1用于top-N报告。perfect:D非常感谢!我不知道你能做那个tablet.orase,非常好的功能!