Reputation: 11
I am trying to run a query in Oracle SQL and am having issues because the query was originally written in a different SQL language. Does anyone know how this Max_by function would be translated to Oracle SQL? I think it's from Presto or MySQL originally. So far I've had no luck figuring out how to re-create it.
MAX_BY(e.new_used_flag||'#'||e.lease_flag||'#'||e.sales_type, e.purchase_dt_key) AS prior_experian
Upvotes: 1
Views: 757
Reputation: 1269623
In Oracle, you can use KEEP
:
MAX(e.new_used_flag || '#' || e.lease_flag || '#' || e.sales_type) KEEP
(DENSE RANK FIRST ORDER BY e.purchase_dt_key DESC) AS prior_experian
Upvotes: 3