显示嵌套 table 列的 table 的 max() 值
Displaying max() value of table that has nested table column
假设我有一个嵌套的 table 叫做 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;
例如,有一种方法可以在一个查询中获取给定年份的所有国家/地区的生产列的最大值吗?
是的,您可以使用 TABLE
功能。
SELECT t.id,
MAX(p.value)
FROM test t
CROSS JOIN TABLE ( production ) p
GROUP BY t.id;
假设我有一个嵌套的 table 叫做 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;
例如,有一种方法可以在一个查询中获取给定年份的所有国家/地区的生产列的最大值吗?
是的,您可以使用 TABLE
功能。
SELECT t.id,
MAX(p.value)
FROM test t
CROSS JOIN TABLE ( production ) p
GROUP BY t.id;