TableBoxes TableItems
BoxCode BoxDesc ItemNo BoxCode ItemDesc
X1 Freight1 123 X1 Tomatoes
X4 Freight2 124 X1 Apples
X8 Freight3 128 X4 Potatoes
I want result row for BoxCode=X1 only, with output ordered by ItemNo
BoxNumber ItemNo ItemDesc
1 1 Tomatoes
1 2 Apples
I can easily get the ‘ItemNo’ serial working by using row_number() on ItemNo. How do I find the serial of the box from the first table ?
My current query
select
row_number() over(
order by a.ItemNo
)as ItemNo
,ItemDesc
from
TableItems a
inner join TableBoxes b
on a.BoxCode=b.BoxCode
where
a.BoxCode='X1'
Can’t figure out how to select serial for BoxCode, Damien.
Is this what you want?