There is a VARCHAR2 type column in my database table for store invoice_number. and there is a query to get max invoice_number as below.
select max(invoice_number) from invoice;
but there are no data in invoice table, above query return value as null. but in this case i need to replace this value to 0 instead of null. how could i do this ?
Using NVL:
Using the ANSI COALESCE:
Using DECODE:
Using the ANSI CASE:
Verdict
All work, I’d probably use NVL because COALESCE is ANSI but not known to necessarily work as fast as native alternatives.