Using oracle 8.
I am using the following query in an oracle function but I want to know if it could be written better. I have a table "my table" which has two sequence numbers "sequence_no" and "seq_no." I want to find the maximum "sequence_no" for a particular key "my_key". But when I find this max sequence_no, I have to find the maximum seq_no within that maximum sequence_no. HOpe I didn't confuse you. Help and Thanks
SELECT decode(my_value,'Y','Fuel'
)
INTO ls_temp
FROM my_table
WHERE
util_name = 'h$_fuel'
AND my_value = 'Y'
AND key = my_key
AND sequence_no =
(SELECT max(sequence_no)
FROM my_table
WHERE util_name = 'h$_fuel' AND key = my_key
)
AND seq_no =
(SELECT max(seq_no)
FROM my_table
WHERE util_name = 'h$_fuel' AND key = my_key
AND sequence_no =
(SELECT max(sequence_no)
FROM my_table
WHERE util_name = 'h$_fuel' AND key = my_key
)
);
Start Free Trial