dipak dutta
dipak dutta

Reputation: 274

Case when then result field shows blank value

This is a portion of my query. I fail to understand where is the problem in my query. The query is not working. It shows blank field.

If I add else 'abc' then 'abc' shows in the field.

case cc.min_col
         when 'sm1' 
         then  (select CASE least(SUM(`j100`), SUM(`j119`), SUM(`j128`))
                                WHEN `j100` THEN '100'
                                WHEN `j119` THEN '119'
                                WHEN `j128` THEN '128'
                                ELSE 'abc'
                                END from `smc1a`)
end) as min_no

Upvotes: 1

Views: 64

Answers (1)

achal naskar
achal naskar

Reputation: 710

Try this

case cc.min_col
         when 'sm1' 
         then  (select CASE least(SUM(`j100`), SUM(`j119`), SUM(`j128`))
                                WHEN SUM(`j100`) THEN '100'
                                WHEN SUM(`j119`) THEN '119'
                                WHEN SUM(`j128`) THEN '128'
                        END from `smc1a`)
end) as min_no

Upvotes: 2

Related Questions