sql - naming a row after using rollup -


having used 'roll up' i'm having issue 2 rows being called 'total'. bottom 'total' should called 'n/a'

  name        col1     col2   total        10       12               5        2     b           4        4     c           0        4       total         1        2 

should this

   name        col1     col2    total        10       12               5        2     b           4        4     c           0        4         n/a         1        2 

this part of query i'm doing wrong

   select     case name when 'n/a' 'total' else name end name         ,col1    ,col2          (        case nameid when '1' 'a'                 when '2' 'b'                 when '3' 'c'                 else 'n/a'     end name     ,col1  --these sums     ,col2  --these sums       table      group nameid rollup        )a 

if make change bit

   case nameid when '1' 'a'                 when '2' 'b'                 when '3' 'c'                 else 'help'     end name  

the outcome

       name        col1     col2               10       12                  5        2        b           4        4        c           0        4                   1        2 

all appreciated, thanks

one of names total seems, why not swap them. seems want.

case    when name =  'n/a' 'total'    when name = 'total' 'n/a'   else name  end name 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -