I have a table that has purchases in it, and the quantity they were bought at, with the price.
I need to break them out into 1 row per item, with the cost of that row.
declare @tableA table
(
Qty Integer,
Name nvarchar(50),
Price decimal(18,2)
)
insert into @tableA (Qty, Name, Price)
values
(5, 'Apples', 1.20),
(2, 'Apples', 1.15),
(3, 'Apples', 1.16),
(6, 'Banana', 2.99),
(2, 'Banana', 2.75),
(1, 'Banana', 3.00)
select * from @tableA
Current result
Qty Name Price
5 Apples 1.20
2 Apples 1.15
3 Apples 1.16
6 Banana 2.99
2 Banana 2.75
1 Banana 3.00
This is what I need returned from the table.
Qty Name Price
1 Apples 1.20
1 Apples 1.20
1 Apples 1.20
1 Apples 1.20
1 Apples 1.20
1 Apples 1.15
1 Apples 1.15
1 Apples 1.16
1 Apples 1.16
1 Apples 1.16