On Sun, Jan 18, 2009 at 7:30 PM, Chris <dmagick@gmail.com> wrote:
> I have a view that looks like this:
>
> SELECT
> CASE
> WHEN r.assetid IS NULL THEN p.assetid
> ELSE r.assetid
> END AS assetid,
> CASE
> WHEN r.userid IS NULL THEN p.userid
> ELSE r.userid
> END AS userid, p.permission, p."granted", p.cascades
> FROM sq_ast_perm p
> LEFT JOIN sq_vw_ast_role r ON r.roleid::text = p.userid::text AND
> r.assetid::text = p.assetid::text;
The effect that you are trying to achieve with CASE statements is
better suited to the COALESCE(...) function.
http://www.postgresql.org/docs/8.3/interactive/functions-conditional.html#AEN14484
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug