Oracle Differences between NVL and Coalesce

COALESCE is more modern function that is a part of ANSI-92 standard. NVL is Oracle specific, it was introduced in 80‘s before there were any standards. In case of two values, they are synonyms. However, they are implemented differently. NVL always evaluates both arguments, while COALESCE usually stops evaluation whenever it finds the first non-NULL … Read more

Combine rows / concatenate rows

Here is a sample User Defined Function (UDF) and possible usage. Function: Function Coalsce(strSQL As String, strDelim, ParamArray NameList() As Variant) Dim db As Database Dim rs As DAO.Recordset Dim strList As String Set db = CurrentDb If strSQL <> “” Then Set rs = db.OpenRecordset(strSQL) Do While Not rs.EOF strList = strList & strDelim … Read more

How to implement coalesce efficiently in R

On my machine, using Reduce gets a 5x performance improvement: coalesce2 <- function(…) { Reduce(function(x, y) { i <- which(is.na(x)) x[i] <- y[i] x}, list(…)) } > microbenchmark(coalesce(a,b,c),coalesce2(a,b,c)) Unit: microseconds expr min lq median uq max neval coalesce(a, b, c) 97.669 100.7950 102.0120 103.0505 243.438 100 coalesce2(a, b, c) 19.601 21.4055 22.8835 23.8315 45.419 100