我在LibreOffice Base中创建了一个带有少量表的简单数据库。 我想运行以下查询:
SELECT SUM( "Total price" ) AS "Expenses" FROM "Expenses" WHERE "the Name of the Ware" IS 'food' AND "Date" BETWEEN {d '2019-08-06' } AND {d '2019-08-20' }
但是我得到一个错误:
SQL状态:37000错误代码:-11
语句[SELECT SUM(“ Total price”)AS中出现意外令牌 “费用”中的“费用”,在“商品名称”中为“食品”,并且 '2019-08-06'和'2019-08-20'之间的“日期”]
可以看到,我正在尝试从“费用”表的记录中获取“总价”值的总和,其中“商品名称”为“食品”,而“日期”在两个给定日期之间。
我如何实现我的目标?
答案 0 :(得分:1)
IS
关键字仅用于NULL和TRUE或FALSE表达式,例如IS NULL
或IS TRUE
您需要改用等号:
SELECT SUM( "Total price" ) AS "Expenses" FROM "Expenses" WHERE "the Name of the Ware" = 'food' AND "Date" BETWEEN {d '2019-08-06' } AND {d '2019-08-20' }