SQLTeam.com | Weblogs | Forums

Arrange data Horizontaly with values


I am having table as mentioned in attached screen where Tagindex containns duplicate entries for taht particular tag i want to use tagindex distict as a header and the value belongs to hat tag will appear below that tagindex as shown in figure attached.is it doable.
SELECT 'TagIndex' AS parameter,
[0], [1], [2], [3], [4]
(SELECT millitm, val
FROM floattable) AS SourceTable
FOR millitm IN ([0], [1], [2], [3], [4])
) AS PivotTable;


IIUC: What you are asking is for SQL to produce a non-relational result. Basically a query that returns rows with multiple, identical column names.

If you get a query that works, and you have four columns called Tagindex, how will you tell them apart?

also, if you paste your source data as:


that it's easier for forum contributors to work with. Not many people would hand-type from your screenshot of the original table.