Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Subtotal when vendorcode changed.

$
0
0
Hi Experts,i need to write a stored procedure for a table with below columnsfor instance the table had 5 columns like VendorCode | UnitPrice | Qty | Total(UnitPrice*Qty) |--------------------------------------------------------V001 | 100 | 10 | 1000V001 | 10 | 20 | 200V222 | 20 | 5 | 100V222 | 5 | 100 | 500 so am writing a Stored Proc to get all the table values like above ., but i need to write Stored Proc in such a way it returnsthe above table like result along with subtotal when ever vendor code changed. as belowVendorCode | UnitPrice | Qty | Total(UnitPrice*Qty) |--------------------------------------------------------V001 | 100 | 10 | 1000V001 | 10 | 20 | 200[b]subtoal 110 30 1200 [/b] ----- this subtoal should be displayed from Stored procedureV222 | 20 | 5 | 100V222 | 5 | 100 | 500[b]subtotal 25 105 600[/b]please help me to acheive thisthank you.

Viewing all articles
Browse latest Browse all 3145

Trending Articles