Q:

select everything with different cases

I would like to select everything from a table based on value of active colum

if active = 1 then selet * 
if active = 0 then select nothing
if active is null then select based on active of parentNode

The table looks like this:
  mytable:
 node | parentNode | active | moreColumns

What I have written is
select *
from mytable
where active = case
           when active = 1 then 1
    case
           when active is null then (select node.active 
                                     from mytable 
                                     where parentNode = node) end;  

The query doesnt work somehow. any suggestion?

A:

You are on the right track.  With a correlated subquery, you need to use table aliases and qualified column names -- good ideas in all queries:
select t.*
from mytable t
where t.active = 1 or
      (t.active is null and
       (select t2.active
        from mytable t2
        where t2.node = t.parentnode
       ) = 1
      )

