How to group and sum data based on dynamic where condition? I have to sum rows based on given dates. I have different dates that will passed as a parameter and have to sum item cost.
Example
Given above image from table without summing item_cost. Here I have to sum item_cost field based on bill_date field. Dates can vary which will be taken from another table and have to sum.
Below is query I have to used to get all item cost with summing
SELECT item_cost,
bill_date
FROM billing
WHERE (bill_date <= "2022-03-30 13:00:00" || bill_date <= "2022-03-30 18:00:00")
Here I have to group and sum item_cost based on given date. Sum of item_cost of bill_date <= "2022-03-30 13:00:00" and in another row bill_date <= "2022-03-30 18:00:00"
