Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

i have following query

SQL
SELECT * FROM
(SELECT     FloatTable.TagIndex, FloatTable.DateAndTime, FloatTable.Val, TagTable.TagName, TagTable.TagIndex AS Expr1, TagTable.[Desc]
FROM         FloatTable INNER JOIN
                      TagTable ON FloatTable.TagIndex = TagTable.TagIndex
                      where TagTable.TagName='ANALOG\TI-1221\VALUE' or TagTable.TagName='ANALOG\TI-1222\VALUE' or TagName='ANALOG\LI-1302\VALUE' or TagName='ANALOG\LI-1303\VALUE' or TagName='ANALOG\LI-1301\VALUE' or TagName='ANALOG\TI-1403\VALUE' or TagName='ANALOG\FI-1405\VALUE' or TagName='ANALOG\FI-1401\VALUE' or TagName='ANALOG\FI-1402\VALUE' or TagName='ANALOG\FI-1404\VALUE' or TagName='ANALOG\TI-1501\VALUE' or TagName='ANALOG\LI-1501\VALUE' or TagName='ANALOG\AI-1502\VALUE' or TagName='ANALOG\FI-1302\VALUE' or TagName='ANALOG\FI-1301\VALUE' or TagName='ANALOG\PI-1401\VALUE' or TagName='ANALOG\TI-1401\VALUE' or TagName='ANALOG\TI-1402\VALUE' or TagName='ANALOG\TI-1404\VALUE' or TagName='ANALOG\AI-1501\VALUE' or TagName='ANALOG\LI-1406\VALUE' or TagName='ANALOG\FLOW-TOTAL-1201\VALUE' or TagName='ANALOG\FLOW-TOTAL-1301\VALUE' or TagName='ANALOG\FLOW-TOTAL-1302\VALUE' or TagName='ANALOG\FLOW-TOTAL-1405\VALUE') MD
PIVOT(max(VAL) FOR TagName IN ([ANALOG\TI-1221\VALUE],[ANALOG\TI-1222\VALUE],[ANALOG\LI-1302\VALUE],[ANALOG\LI-1303\VALUE],[ANALOG\LI-1301\VALUE],[ANALOG\TI-1403\VALUE],[ANALOG\FI-1405\VALUE],[ANALOG\FI-1401\VALUE],[ANALOG\FI-1402\VALUE],[ANALOG\FI-1404\VALUE],[ANALOG\TI-1501\VALUE],[ANALOG\LI-1501\VALUE],[ANALOG\AI-1502\VALUE],[ANALOG\FI-1302\VALUE],[ANALOG\FI-1301\VALUE],[ANALOG\PI-1401\VALUE],[ANALOG\TI-1401\VALUE],[ANALOG\TI-1402\VALUE],[ANALOG\TI-1404\VALUE],[ANALOG\AI-1501\VALUE],[ANALOG\LI-1406\VALUE],[ANALOG\FLOW-TOTAL-1201\VALUE],[ANALOG\FLOW-TOTAL-1301\VALUE],[ANALOG\FLOW-TOTAL-1302\VALUE],[ANALOG\FLOW-TOTAL-1405\VALUE]))PIVOTDATA






but max(val) for all columns showing null value

but they actaully containing values
Posted
Comments
Maciej Los 23-May-14 6:29am    
Post sample data and expected output.

1 solution

Sorry, but your question is not clear.

I'd suggest to start here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900