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 |
eschwartz
Starting Member
2 Posts |
Posted - 2015-02-24 : 13:08:29
|
I have a single table listing products, company, sales and quarter and need to subtract sales values of one product from another product for each company per quarter. For example: company aaaa = product B sales - product A sales in q1. Any suggestions?product company sales quarterA aaaa 1234 q1A cccc 1235 q1B aaaa 8234 q1B cccc 8235 q1A aaaa 4567 q2A cccc 4568 q2B aaaa 3567 q2B cccc 3568 q2 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-02-24 : 14:11:51
|
I'm not sure understanding what you want. Given your sample data, what is the expected output?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
eschwartz
Starting Member
2 Posts |
Posted - 2015-02-24 : 14:36:10
|
basically, i need a query that checks if a company sold product B in a quarter, and then subtracts the sales number for product b from the sales number for product a in the same quarterthe output would look like..product company sales quarter(a - b) aaaa (1234 - 8234) q1i realize the example data will have a negative number, but thats ok as long as the query works. i can fix any negative numbers later. |
|
|
|
|
|