2017-02-23 134 views
0

我試着時聲明,但我在PostgreSQL中得到一個語法錯誤,把兩個條件的情況下,內部CASE WHEN條件1和條件2,則x其他ŸPostgreSQL的

case when 
condition 1 and condition 2 then X else Y 
condition 3 and condition 4 then Z else Y 

end 

什麼是正確的語法有在這兩種情況下,列都是x,否則是y?

回答

2

試試這個方法:

case 
    when condition 1 and condition 2 then X 
    when condition 3 and condition 4 then Z 
    else Y 
end