title: Optimize a NULL / NOT NULL flags PostgreSQL query
body: <p>I am trying to get one record that contains boolean flags: true if a column in specific result set has at least one NOT NULL value and false if all the values are NULL.</p>
  
  <p>Sample data of a result set </p>
  
  <pre><code>SELECT "my column 1", "my column 2", "my column 3", "my column 4", "my column 5" 
  FROM my_data 
  WHERE date BETWEEN :start AND :end
  
  "my column 1" "my column 2" "my column 3" "my column 4" "my column 5"
     NULL          NULL          25.2          NULL          1.12
     15.28         NULL          NULL          NULL          2.25
     NULL          NULL          13.9          NULL          3.03
     359.00        NULL          125.5         NULL          4.15
     NULL          NULL          152.2         NULL          5.99
     NULL          NULL          NULL          NULL          6.35
  </code></pre>
  
  <p>In this case result should be:</p>
  
  <pre><code>"my column 1" "my column 2" "my column 3" "my column 4" "my column 5"
     t             f             t             f             t
  </code></pre>
  
  <p>A following PostgreSQL query does exactly what I need (actually it terminates each subquery as soon as first NOT NULL value has been detected), but could it be be optimized?:</p>
  
  <pre><code>WITH x AS (SELECT * FROM my_data WHERE date BETWEEN :start AND :end)
  
  SELECT
      EXISTS(SELECT * FROM x WHERE "my column 1" IS NOT NULL) AS "my column 1",
      EXISTS(SELECT * FROM x WHERE "my column 2" IS NOT NULL) AS "my column 2",
      EXISTS(SELECT * FROM x WHERE "my column 3" IS NOT NULL) AS "my column 3",
      EXISTS(SELECT * FROM x WHERE "my column 4" IS NOT NULL) AS "my column 4",
      EXISTS(SELECT * FROM x WHERE "my column 5" IS NOT NULL) AS "my column 5"
  </code></pre>
  
  <p>I thought it could be written either shorter or universally, without mentioning each column name.</p>