I want to accomplish the following in SQL Server 2008
I have an article table like follows
| ArticleId | Description |
|-----------+-------------|
| 1 | Test |
|-----------+-------------|
And a order forecast table like this.
| ArticleId | Week | Order | Amount |
|-----------+--------------+--------+
| 1 | 51 | 1 | 0 |
| 1 | 52 | 2 | 150 |
| 1 | 1 | 3 | 0 |
| 1 | 2 | 4 | 200 |
| 1 | 3 | 5 | 0 |
|-----------+------+-------+--------+
Is there a way to create a query the produces a column for each record in the forecast table in the order of the order
column. If it's possible how could I do that?
| ArticleId | Description | Week51 | Week52 | Week1 | Week2 | Week3 |
|-----------+-------------+-----------------+-------+-------+-------+
| 1 | Test | 0 | 150 | 0 | 200 | 0 |
|-----------+-------------+--------+--------+-------+-------+-------+