Conditional SQL where clause
sql, sql-server
Solution
SELECT COALESCE(b.logo, dflt.logo) AS logo
FROM mytable dflt
LEFT OUTER JOIN mytable b ON b.customerid=5
WHERE dflt.customerid=18
Problem
I am storing logos in a varbinary(max) field. I'm looking for an SQL statement that says, `select logo where customerid=5` but if the logo for a particular customerid is NULL, then, `select logo where customerid=18` which is the default logo. I'd like to do this in a single query if possible. Can this be done? Thanks.