SELECT
TO_CHAR(order_date, 'YYYY-MM'),
product_id,
SUM(quantity) sum_quan,
ROW_NUMBER() OVER ( ORDER BY order_date) RN
FROM customer_orders
WHERE 1 = 1
AND product_id = 2
AND To_char(order_date, 'YYYY-MM') BETWEEN To_char(Add_months(order_date, -1), 'YYYY-MM') AND To_char(order_date, 'YYYY-MM')
GROUP BY 1,2;
HI, I have problem with GROUP BY with TO_CHAR FUNCTION. Does anyone know how this can be fixed?
Maybe you just need this, and I am guessing here. And I do not understand why you have the row_number()