1. Pushing "1 column, many rows" into "1 row, many columns"
Manning,
select CUST_ID,
SC_1 = sum (case when STATUS_CODE = 1 then VALUE else 0 end),
SC_2 = sum (case when STATUS_CODE = 2 then VALUE else 0 end),
SC_3 = sum (case when STATUS_CODE = 3 then VALUE else 0 end)
from <tablename>
group by CUST_ID
HI - I'm stuck. Any help would be hugely appreciated.
I have a table with data like below:
CUST_ID STATUS_CODE VALUE
1 1 10
1 2 15
1 3 20
I need to push this around so I get a single row of data like this:
(where SC = status code)
CUST_ID SC_1 SC_2 SC_3
1 10 15 20
I know how to do it in Excel, but there are around 500K records which makes it impossible. Also, there will be status columns for which a given customer does not have a corresponding record.
Any help will be much appreciated.
Manning Bartlett
Sydney Australia
2. partitioning indexed views
3. Problem with Column.Properties("Default")
4. Spin Control and DAO
5. How to "SELECT" rows as columns
6. SQL server 4.21 via ODBC in Delphi 1.02
7. max of ("...","...","..")
8. Help Entity Relationships
9. Default Dimension for Rows & Columns
10. "Add column" not as last column
11. "Hidden" Dimension
12. "Optional" Page Axis Dimension in MDX
13. Create "replacement" labels for a dimension