I started the question here ( Query to get the most recent record and with the higher value) but I have a small change request.
I will have a column with Percentage and another column with a Char to indicate if is a value or a percentage.
I am trying to do something like this:
select card,
service,
max(date),
case when type = 'v'
then
MAX(value) KEEP (
dense_rank first order by date desc
)
else
max(percentage) valor keep (
dense_rank first order by date desc
) end
from table
group by card,
service;
But I am getting ORA-00979: not a GROUP BY expression.