|
please ignore my poor english...
I Need Reporting This Table in this shape.plz help me...
SQL Table
----------
City Value
-- --
Londen 20
Tehran 12
Paris 15
Londen 12
My Needed Report
----------
Londen Tehran Paris
---- ---- ----
32 12 15
modified 26-Jan-13 8:52am.
|
|
|
|
|
You need to use SQL PIVOT:
MSDN: Using PIVOT and UNPIVOT[^]
Try:
SELECT
'TotalValue' AS Sum_Total_Values_By_City, [London], [Tehran], [Paris]
FROM
(SELECT City, Value
FROM MyTable) AS SourceTable
PIVOT
(
SUM(Value)
FOR City IN ([London], [Tehran], [Paris])
) AS PivotTable
|
|
|
|