sql - select multiple fields from most recent record from an oracle table -
i want this:
select max(field1), field2 tbl1 group field1
but above query doesn't work (sqlplus throws error). how can achieve above in single query (for now, have split 2 queries result).
you use inline view , analytic function (max() over()
) in selecting row(s) largest timestamp:
select field1, field2 (select field1, field2, max(field1) over() max_field1 tbl1) field1 = max_field1;
note if there many records timestamp value of max_field1
, returned (in arbitrary order).
Comments
Post a Comment