<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: list() in a case statement in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaa-p/13836094#M4866937</link>
    <description>&lt;P&gt;LIST &lt;EM&gt;does&lt;/EM&gt; work in a CASE expression. The following is a (not very useful) sample:&lt;/P&gt;

&lt;LI-CODE lang="sql"&gt;select case
  when creator &amp;lt;&amp;gt; 3
  then 'System procs: ' || list(proc_name, ', ' order by proc_name)
  else 'My procs: ' || list(proc_name, ', ' order by proc_name)
end case as MyProcList
from sysprocedure group by creator
&lt;/LI-CODE&gt;

&lt;P&gt;Note, however, that &lt;STRONG&gt;LIST is an aggregate function&lt;/STRONG&gt;, i.e. the &lt;EM&gt;[field]&lt;/EM&gt; you refer to in the CASE WHEN expression must be part of the &lt;STRONG&gt;GROUP BY clause&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;That's the reason I used "GROUP BY creator".&lt;/P&gt;

&lt;P&gt;As to your notation of (list[y], [z]): Note that LIST is not a string concatenation, instead it lists all particular values per group. A simple string concatenation can be done with operator || (as in the sample) or the STRING function.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Feb 2011 16:55:58 GMT</pubDate>
    <dc:creator>VolkerBarth</dc:creator>
    <dc:date>2011-02-24T16:55:58Z</dc:date>
    <item>
      <title>list() in a case statement</title>
      <link>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaq-p/13836093</link>
      <description>&lt;P&gt;Wondering if anyone can shed some light on the possibilies of having a list() in a case statement. ex: &lt;/P&gt;

&lt;LI-CODE lang="sql"&gt;select (case
  when [field] = [x] then list([y], [z])
else [a]
end)
from [table]
&lt;/LI-CODE&gt;

&lt;P&gt;couldn't find any documentation and the list() function seems a bit limited from the documents info. &lt;/P&gt;

&lt;P&gt;Appreciate your help.  I'm using sql anywhere 11. &lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 15:49:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaq-p/13836093</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-24T15:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: list() in a case statement</title>
      <link>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaa-p/13836094#M4866937</link>
      <description>&lt;P&gt;LIST &lt;EM&gt;does&lt;/EM&gt; work in a CASE expression. The following is a (not very useful) sample:&lt;/P&gt;

&lt;LI-CODE lang="sql"&gt;select case
  when creator &amp;lt;&amp;gt; 3
  then 'System procs: ' || list(proc_name, ', ' order by proc_name)
  else 'My procs: ' || list(proc_name, ', ' order by proc_name)
end case as MyProcList
from sysprocedure group by creator
&lt;/LI-CODE&gt;

&lt;P&gt;Note, however, that &lt;STRONG&gt;LIST is an aggregate function&lt;/STRONG&gt;, i.e. the &lt;EM&gt;[field]&lt;/EM&gt; you refer to in the CASE WHEN expression must be part of the &lt;STRONG&gt;GROUP BY clause&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;That's the reason I used "GROUP BY creator".&lt;/P&gt;

&lt;P&gt;As to your notation of (list[y], [z]): Note that LIST is not a string concatenation, instead it lists all particular values per group. A simple string concatenation can be done with operator || (as in the sample) or the STRING function.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 16:55:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaa-p/13836094#M4866937</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-02-24T16:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: list() in a case statement</title>
      <link>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaa-p/13836095#M4866938</link>
      <description>&lt;P&gt;Volker, great stuff with the ||.  That did the trick.  And, I appreciate the notes on LIST.  Helped tremendously.  Thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 17:48:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/list-in-a-case-statement/qaa-p/13836095#M4866938</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-24T17:48:48Z</dc:date>
    </item>
  </channel>
</rss>

