IF ELSE 与 DBISAM SQL
我正在使用 DBISAM 运行以下查询。
SELECT((SUM(sales.sale_amount)
+SUM(sales.vat_amount))
-SUM(payments.fee_amount))
AS Balance,account_details.id FROM account_details
JOIN sales ON account_details.id = sales.account_id
JOIN payments ON account_details.id = payments.account_id GROUP BY account_details.id
但是,有 3 种不同类型的销售 - sales.sale_type 等于 0、1 或 2。如果为 0,则应添加正的 sale_amount 和 vat_amount,否则应使用负值。
我尝试了各种方法
IF(sales.sale_type=0)
BEGIN
...
END
ELSE
BEGIN
...
END
都无济于事,只遇到脚本甚至无法运行的错误。我不知道这些错误是否仅限于 DBISAM 还是我的 SQL 本身。
任何帮助表示赞赏。
谢谢
I am running the following query using DBISAM
SELECT((SUM(sales.sale_amount)
+SUM(sales.vat_amount))
-SUM(payments.fee_amount))
AS Balance,account_details.id FROM account_details
JOIN sales ON account_details.id = sales.account_id
JOIN payments ON account_details.id = payments.account_id GROUP BY account_details.id
However, there are 3 different types of sale - sales.sale_type equating to 0, 1 or 2. If it is 0 a positive sale_amount and vat_amount should be added, ELSE negative values should be used.
I've tried various
IF(sales.sale_type=0)
BEGIN
...
END
ELSE
BEGIN
...
END
To no avail, encountering only errors with the script not even runnning. I don't know if these errors are confined to DBISAM or it is my SQL in general.
Any help appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DBISAM 有 CASE 语句吗?
Does DBISAM have CASE statements?