SELECT CASE: more than one row returned by a subquery used as an expression
<p>I got very good help for my question <a href="https://stackoverflow.com/questions/34771537/postgresql-return-message-after-count-0">PostgreSQL: return message after count = 0</a></p>

<p>This query works fine:</p>

<pre><code>SELECT  CASE WHEN COUNT(*)  = 0 THEN 'NO RESULT'
            ELSE CAST(COUNT(*) as TEXT)
        END as myfield from mytable
</code></pre>

<p>But today I need if some rows are in table, I need to show select result.</p>

<p>I tried:</p>

<pre><code>SELECT  CASE WHEN COUNT(*)  = 0 THEN 'NO RESULT'
             ELSE (select name from mytable)
        END as myfield from mytable
</code></pre>

<p>And I got error:</p>

<blockquote>
  <p>ERROR:  more than one row returned by a subquery used as an expression</p>
</blockquote>

<p>I found that <code>IN</code> function but don't have any idea to improve it. </p>