2019-03-26 postgresql if postgresql postgresqlにifはないっぽいのでcase whenなどを使う https://www.postgresql.jp/document/9.4/html/functions-conditional.html