I want to do an insert using a CASE statement in PostgreSQL.
I am trying to do an insert if the count of my result set is equal to zero. If it isn't equal to zero, then I just want to do a select of the max time on that table.
select
    case
        when (select count(*) from x where TableName = 'p' ) > 0
              then
             (select    MaxDataDate from    x where TableName = 'p' ) 
        when (select count(*) from s where TableName = 'p') = 0
              then
             (insert into x values('p','1900-01-01'))
end
 
     
    