sql - inserting if in a select query -


how can ?

select    (if(sum(costo) > 0) sum(costo) else 0) expr1         tdp_notaspesesezb 

you want use case statement.

select    case when sum(costo) > 0 sum(costo)    else 0    end 'expr1'   tdp_notaspesesezb 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -