I have a where i store orderrows (salesrow_id), so one line of an invoice, which is part of a order order_id and the price paid for that item
salesrow_id(pk) | order_id | price | name
10 1 5 spaghetti
11 1 4 pizza
12 2 6 salami
13 1 1 vegetables
What i am trying to achieve is to have get the rownumber on the invoice, by order_id and salesrow_id. For example: salesrow_id=13, order_id=1 should return 3, since it's the third item on my invoice for order 1, if sorted by salesrow_id.
I've tried querying using row_number but that works only if i return multiple rows, and i would just like to have the number 3 as a single result.
Could someone push me in the right direction?