Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
joe8079
Posting Yak Master
127 Posts |
Posted - 2012-01-25 : 16:23:03
|
Hello, I hope this formats correctly, but I'm having some issues creating a new column that calculates the Amount difference between Jan 1, Product A, Description A andJan 2, Product A, Description A For this example, it would display 34345 - 8798 = 25547.I know this involves a sub query in the select statement, but I cannot figure out to do this. I hope this example makes sense. Code: Select date, product, product_descr, sum(amount) as amountFrom table1Group by Date, Product, Product_descrResults SampleDate Product Product_Descr Amount Jan 1 A Description A 34345Jan 1 A Description B 4658Jan 1 A Description C 859Jan 1 A Description D 6546Jan 2 A Description A 8798Jan 2 A Description B 3245Jan 2 A Description C 2222 Jan 2 A Description D 5688 |
|
|
|
|