So, here is my query. I’m using MariaDB for database. I am relatively new in this sql database. The error that was given is You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SUM(IF(t1.posting_date BETWEEN '2021-01-01' AND '2021-01-31', t2.base_net_amo...' at line 1
. I already tried several things and still nothing.
select t2.item_code, t2.item_name, t1.no_jo, SUM(IF(t1.posting_date BETWEEN '2021-01-01' AND '2021-01-31', t2.stock_qty, NULL),SUM(IF(t1.posting_date BETWEEN '2021-01-01' AND '2021-01-31', t2.base_net_amount, NULL)),
SUM(IF(t1.posting_date BETWEEN '2021-02-01' AND '2021-02-28', t2.stock_qty, NULL),SUM(IF(t1.posting_date BETWEEN '2021-02-01' AND '2021-02-28', t2.base_net_amount, NULL)),
SUM(IF(t1.posting_date BETWEEN '2021-12-01' AND '2021-12-31', t2.stock_qty, NULL),SUM(IF(t1.posting_date BETWEEN '2021-12-01' AND '2021-12-31', t2.base_net_amount, NULL)),
SUM(t2.stock_qty), SUM(t2.base_net_amount)
from `tabBAST` t1, `tabBAST Item` t2
where t2.parent = t1.name and t1.company = %s and t1.transaction_date between %s and %s and t1.docstatus = 1
group by t2.item_code;
Can someone help me find where is the problem ? Thank you