I have this stored procedure. How can I select a variable as a field that can +1 value in every row of results of sp? I need it for making a virtual id field. please help me.
x
CREATE DEFINER=`root`@`localhost` PROCEDURE `customer_order$count_order_by_month`()
BEGIN
select count(1) as amount, month(created_date) as months, year(created_date) as years
from customer_order
group by { fn month(created_date) }, MONTH(created_date), YEAR(created_date)
order by Year(created_date), month(created_date);
END
Advertisement
Answer
Do you simply want row_number()
?
select row_number() over (order by min(created_date)) as seqnum,
count(1) as amount, month(created_date) as months, year(created_date) as years
from customer_order
group by { fn month(created_date) }, MONTH(created_date), YEAR(created_date)
order by Year(created_date), month(created_date);