I'm struggling to write a query to return a very specific set of data and could do with some help in achieving the desired results.
I have four sets of data, structurally similar, in 4 different tables, each in their own database on the same SQLServer 2008 server.
Here's an example of the relevant fields from each table:
Name, Qty1, Qty2, Qty3, Qty4, TotalPrice1, TotalPrice2, TotalPrice3, TotalPrice4
What I need to do is get the individual price (TotalPrice1 / Qty1) for each TotalPrice and fit it into a band based on the value:
0-150, 151-200, 201-250, 251+
Then I want to display a total of the Qty within each band grouped by the Name field, so I should have something like this:
Name Band Qty
John 0-150 5
John 151-200 12
John 201-250 19
John 251+ 3
I guess my first question would be - is this even possible?
If so, how do I get started and which commands do I need to look into?