Haas C
2012-01-31 00:56:19 UTC
I posted this before and got the wrong answer - can someone please
help?:
-------
Hello all!
I'm a newbie with SQL and I've run into a wall here trying to figure
the best way to write a query in SQL Server 2008 to get my desired
results. Here's the scenario:
I have a table named tblProfit. There are only three fields in the
table: ROL, Year, and NetProfit - here's what I need to achieve:
I want the query to return aggregated values of NetProfit by Year
based on the following ROL ranges:
0% to 25%
25.1% to 50%
50.1% to 100%
I have four Years worth of data in the table: 2008, 2009, 2010, and
2011. I'd like my output show the ranges above - so something like
this (the first row below represents output table headers:
ROL_1, ROL_2, Year, NetProfit
0%, 25%, 2008, 1000000
25.1%, 50%, 2008, 4000000
50.1%, 100%, 2008, 3500000
etc. for each of the years (Also, ROL field has everything in
decimals, i.e. 0.25 is 25% but I can make that formatting once I have
the output)
Any and all help would be appreciated - thanks!
help?:
-------
Hello all!
I'm a newbie with SQL and I've run into a wall here trying to figure
the best way to write a query in SQL Server 2008 to get my desired
results. Here's the scenario:
I have a table named tblProfit. There are only three fields in the
table: ROL, Year, and NetProfit - here's what I need to achieve:
I want the query to return aggregated values of NetProfit by Year
based on the following ROL ranges:
0% to 25%
25.1% to 50%
50.1% to 100%
I have four Years worth of data in the table: 2008, 2009, 2010, and
2011. I'd like my output show the ranges above - so something like
this (the first row below represents output table headers:
ROL_1, ROL_2, Year, NetProfit
0%, 25%, 2008, 1000000
25.1%, 50%, 2008, 4000000
50.1%, 100%, 2008, 3500000
etc. for each of the years (Also, ROL field has everything in
decimals, i.e. 0.25 is 25% but I can make that formatting once I have
the output)
Any and all help would be appreciated - thanks!