I have a problem with making the equivalent of row_number in mysql. Here is my code:
SELECT
@row_number:=CASE
WHEN @facebookv = a.facebook THEN @row_number:= @row_number + 1
ELSE @row_number:=1
END AS num,
@facebookv:=a.facebook as denumire_facebook,
a.Keyword,
sum(a.Sales) as Sales
FROM
ams_prod a , (SELECT @row_number:=0,@facebookv='') AS t
group by a.facebook,a.Keyword
having sum(a.Sales)>0
ORDER BY a.facebook;
So the problem is that it is returning me the same "num" for the same "facebook" column value like:
And no, they are not doubled, they are just repeating a couple of times. Any idea why is this happening? Thanks!