Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Is it possible to replace values in a Rollup?
    primarykey
    data
    text
    <p>I have a result set that mainly consists of columns of values. However, the left most column contains text which I'm using to effectively label each row. When I ROLLUP, the values total, which is great. The text in my 'No KS2' column rolls up to a NULL which is expected. Is there anything I can do to replace the NULL with text eg 'Total'?</p> <p>All the NULLs in the other columns should be there and I don't need to replace those.</p> <p>Here's an example of my results set eg:</p> <pre><code>No KS2 6c/D- 6b/D 6a/D+ 2a 1 NULL NULL 3c 3 NULL NULL 3b NULL 5 NULL 3a NULL NULL 6 NULL 4 5 6 </code></pre> <p>Here's what I'd like to do:</p> <pre><code>No KS2 6c/D- 6b/D 6a/D+ 2a 1 NULL NULL 3c 3 NULL NULL 3b NULL 5 NULL 3a NULL NULL 6 Total 4 5 6 </code></pre> <p>EDIT:</p> <p>When generating the KS2 column results set using the group by I have already replace NULL values with 'No KS2'. Please see my GROUP BY code below:</p> <pre><code>GROUP BY CASE Name WHEN 'English' THEN CASE WHEN [Ks2en] IS NULL OR [Ks2en]='' THEN 'No KS2' WHEN [Ks2en] IN ('1a','1b','1c') THEN '1' ELSE [Ks2en] END WHEN 'Mathematics' THEN CASE WHEN [Ks2ma] IS NULL OR [Ks2ma]='' THEN 'No KS2' WHEN [Ks2ma] IN ('1a','1b','1c') THEN '1' ELSE [Ks2ma] END ELSE CASE WHEN [Ks2av] IS NULL OR [Ks2av]='' THEN 'No KS2' WHEN [Ks2av] IN ('1a','1b','1c') THEN '1' ELSE [Ks2av] END END WITH ROLLUP </code></pre> <p>EDIT: This isn't a duplicate as the solution to the question that this is supposed to be a duplicate of does not resolve my issue. I edited the code to explain the difference. I already have a case statement that replaces out my NULL values in the KS2 column with 'No KS2'.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload