如何查询varray
内的最大值?
create type myWave as varray(10) of int;
create table foo (id number, yVals myWave);
insert into foo values (1, myWave(1, 8, 5));
insert into foo values (2, myWave(1, 3, 4));
insert into foo values (3, myWave(9, 5, 9));
insert into foo values (4, myWave(8, 2));
SQL不正确:SELECT id, MAX(yVals) maxY FROM foo
期望的输出:
| id | maxY |
|----|------|
| 1 | 8 |
| 2 | 4 |
| 3 | 9 |
| 4 | 8 |
答案 0 :(得分:2)
SELECT t1.ID, MAX(t2.column_value) FROM foo t1, TABLE(t1.yVals) t2 group by t1.ID