sql - COALESCE in Where clause? -
is there way express within sql select specific row if column matched, otherwise select more general row? like:
select name names (cola = @cola or cola = 'all') i want return 1 specific record if exists, otherwise return generic "all" record if can't find specific column match. seems coalesce similar i'm looking for, don't know how work here syntactically.
@blorgbeard answer (using top 1 , order by) best way different use sub-query , not exists:
select name names (cola = @cola) or (cola = 'all' , not exists( select name names cola = @cola)) i guess "advantage" of uses more standard sql.
Comments
Post a Comment