Zahid

Please help me to understand following codes

case 

    when grouping (case when 1=0 then null else cscust end) = 0 then 4      

when grouping (case when a.cgmnum is not null then a.cgmgrp else char(cscust) end) = 0 then 3 

when grouping (case when b.cgmnum is not null then trim(b.cgdnam) end) = 0 then 2

when grouping (case when 1=0 then null else csctlb end) = 0 then 1 else 0

end as levelbrk 
 

following also

group by grouping sets ( (case when 1=0 then null else csctlb end,
                   case when b.cgmnum is not null then trim(b.cgdnam) end,
                   case when a.cgmnum is not null then a.cgmgrp else char(cscust) end,
                   case when a.cgmnum is not null then trim(a.cgdnam) else trim(csnam1) end,

(case when 1=0 then null else cscust end),csnam1),
                  (case when 1=0 then null else csctlb end,case when b.cgmnum is not null then trim(b.cgdnam) end,
                   case when a.cgmnum is not null then a.cgmgrp else char(cscust) end,case when a.cgmnum is not null then trim(a.cgdnam) else trim(csnam1) end),

(case when 1=0 then null else csctlb end,case when b.cgmnum is not null then trim(b.cgdnam) end),(case when 1=0 then null else csctlb end),())) 
        

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 2 mths agoLast active
  • 20Views
  • 1 Following