显示具有嵌套表格列的表格的max()值

时间:2019-01-04 05:38:04

标签: database oracle abstract-data-type

让我说我有一个称为test的嵌套表:

create table test(
     id int,
     name varchar2(20),
     production row_type_value,
     constraint pk_country primary_key(id)
) nested table production store as country_production;

类型为:

    create or replace type type_value as OBJECT(
        year int,
        value int
    );
    /
    create or replace type row_type_value as table of type_value;

有没有一种方法可以在一个查询中获取例如给定年份的所有国家/地区的生产列的最大值(值)?

1 个答案:

答案 0 :(得分:1)

是的,您可以使用TABLE函数。

SELECT t.id,
       MAX(p.value)
FROM test t
CROSS JOIN TABLE ( production ) p
GROUP BY t.id;

Demo

相关问题