i have the following table
Prod_id Units sold
1, 100
2, 95
3, 84
4, 95
5, 100
I want to know why the first query gives proper row counts while the 2nd one returns only 1's
select
(ROW_NUMBER() OVER (Partition by amount order by id))
from Products
select *,
(select ROW_NUMBER() OVER (Partition by amount order by id) a )
from Products
Results are here: http://sqlfiddle.com/#!6/dfd59/11
I want to use this to apply 100, 100 1st and 5th
rows and 95, 95 to the 2nd and 4th rows within this query
without using a with
statement.
Please let me know if there is a way