Em 15-12-2011 17:59, Paulo Henrique escreveu: > Marcelo usa o CASE. > > Ex: > SELECT A.COD_CLI, CASE WHEN C.NOME is null then A.NOME ELSE C.NOME END, > B.VALOR > FROM VENDAS A > LEFT JOIN CLIENTES B ON(B.COD_CLI = A.COD_CLI) > LEFT JOIN INDICADOR C ON(C.COD_CLI = A.COD_CLI)
Melhor ainda, use COALESCE, conforme o manual [1]: " The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display, for example: -- SELECT COALESCE(description, short_description, '(none)') ... -- " [1] http://www.postgresql.org/docs/current/static/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL -- Dickson S. Guedes mail/xmpp: gue...@guedesoft.net - skype: guediz http://guedesoft.net - http://www.postgresql.org.br http://github.net/guedes - twitter: @guediz _______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral