# Related Sites > SQL Course >  Complex sql query

## Alucard

I have a table which consist of four fields.

-----------------------
FieldA | FieldB|FieldC|FieldD
-----------------------
1       |test 1|5       |d
1       |test 2|6       |f
1       |test 3|0       |w
2       |test 3|5       |r
2       |test 2|5       |y
2       |test 1|5       |e

How do I display the data using complex sql query if possible or using excel pivot to show the following:

FieldA | Sum of Field C for same A value |test1|test2|test3|
----------------------------------------------------------
1        |5+6+0                                   |d      |f      |w  
2        |5+5+5                                   |r      |y      |e 

I may use group by FieldA to do the sum. But the later part where each of the rows of FieldB changes to columns ..seems struck me..

Thanks.

Regards
Alucard

----------

