I need some help writing a select statement (I still don't think in sets!). Here's the scenario: I have table A with column "Name varchar(20)". I have table B with column "SearchTerm varchar(20)". I ...
“For each group of results fullfilling condition X, select only result with smallest column value A”
I have a table with data and dates like so: DECLARE @p TABLE (P_key int, P_Data char(1), P_ValidUntil datetime) INSERT @p VALUES (20, 'T', '2003-02-28') INSERT @p VALUES (21, 'U', '2005-05-31') ...
I would like to use a default value for a column that should be used if no rows is returned. Is that possible in PostgreSQL? How can I do it? Or is there any other way I can solve this? E.g. ...