本文介绍了如何在单个SQL语句(MySQL)中组合if语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 我坚持使用包含以下计算的SQL语句: 我在我的数据库中有三个表foto 1.rates(rate_id,price,frequency),2.rate_changes(old_rate_id,new_rate_id,photographer_id)和付款(创建,amount_net) 此外,我想根据价格频率计算每月的amount_net,但我不确切知道该怎么做:
hi everyone, I´m stuck on a SQL statement which contains the following calculation: I have three tables in my database foto 1.rates (rate_id, price, frequency),2.rate_changes (old_rate_id, new_rate_id, photographer_id) and payments (created, amount_net) Further, I want to calculate the amount_net per month depending on the rate frequency but I dn´t know exactly how to do it:
SELECT sum( if foto.rates.frequency = 1 then (sum foto.payments.amount_net(month x)) elseif foto.rates.frequency = 3 then (foto.payments.amount_net (month x)/foto.rates.frequency) And foto.payments.amount_net (month x-2)+foto.payments.amount_net (month x)/foto.rates.frequency, foto.payments.amount_net (month x-1) + foto.payments.amount_net (month x)/foto.rates.frequency elseif foto.rates.frequency = 6 then..(the same calculation as in the case before) elseif foto.rates.frequency = 12 then..(the same calculation as in the cases before)) End非常感谢您的帮助!
Thanks a lot in advance for your help!
推荐答案您好, 如何尝试使用某个功能?这对你想要达到的结果很有帮助。 Hello, How about trying to use a function? That would be helpful in the result you want to achieve.
更多推荐
如何在单个SQL语句(MySQL)中组合if语句?
发布评论