Difference between decode and case when: sum (decode (sign (xingji-6), '', h. real_count, 1, h. real_count, 0) compared with case when, the function cannot use and to connect multiple conditions, but can only use function nesting such as sum (decode (sign (xingji-6 ), -1, decode (hh. quxian, 18, h. real_count, 19, h. real_count, 20, h. real_count, 24, h. real_count,
34, h. real_count, 35, h. real_count, 0), 0) www.2cto.com sum: sum (case when start_time = '24' then quantity else 0 end) case when looks a little bloated, however, it is convenient to connect multiple conditions, for example, sum (case when
Start_time = '24' and city_code = '010' then quantity else 0 end) Note: The sum () function is used for summation, and the sign () function is used to return parameters greater than 0, or less than 0 or equal to 0,
An exception is null: ''. For example, sign (1) ---> 1, sign (-1) --->-1, sign (0) ---> 0, sign (null) ---> '';