Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Is it Possible with a Complex Query?

$
0
0
Hi to All,

Excuse for the perhaps hard question.

I have a table "invoice_lines" of the form:
Code:

Year  |week        |item        |matter        |total|
      +        +      +
2012  |1          |book_1 |Philosopy      |37,50|
2012  |1          |book_1 |Philosopy      |37,50|
2012  |1          |book_2 |Story          |47,50|
2012  |1          |book_2 |Story          |47,50|
2012  |2          |book_1 |Philosopy      |37,50|
2012  |2          |book_2 |Story          |47,50|
2012  |2          |book_2 |Story          |47,50|
2012  |3          |book_1 |Philosopy      |37,50|
2012  |3          |book_1 |Philosopy      |37,50|
2012  |3          |book_1 |Philosopy      |37,50|
2012  |3          |book_2 |Story          |47,50|
2012  |3          |book_2 |Story          |47,50|
2012  |3          |book_2 |Story          |47,50|
2012  |4          |book_2 |Story          |47,50|

Strating from this table, I'd want arrive to obtain a view as:

Code:

Year |    matter  |total_week1 |total_week2  |total_week3  |total_week4|... total_week53|
    +            +            +            +            +
2012 |    Philosopy|      75,00 |      37,50 |      112,50|          0|              0|
2012 |        Story|      95,00 |      95,00 |      142,50|      47,50|              0|

Could SomeOne tell if is it possible?

If yes, trough which query?

Tanks in advance

Gianni Pinna.

Viewing all articles
Browse latest Browse all 13329

Trending Articles