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

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -