本文介绍了枢轴查询没有任何聚合函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你好 i有以下查询 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 其中 TagTable .TagName = ' ANALOG\TI-1221 \VALUE' 或 TagTable.TagName = ' ANALOG\TI-1222 \ VALUE ' 或 TagName = ' ANALOG \ LI-1302 \VALUE' 或 TagName = ' ANALOG \LI-1303 \ VALUE' 或 TagName = ' ANALOG \LI-1301 \VALUE' 或 TagName = ' ANALOG\TI-1403 \ VALAL' 或 TagName = ANALOG \FI-1405 \ VALAL' 或 TagName = ' ANALOG\FI-1401 \VALUE' 或 TagName = ' ANALOG\FI-1402 \\ \\ _VALUE' 或 TagName = ' ANALOG \ FII-1404 \VALUE' 或 TagName = ' ANALOG\TI-1501 \VALUE' 或 TagName = ' ANALOG \LI-1501 \VALUE' 或 TagName = ' ANALOG\AI-1502 \ VALAL' 或 TagName = ' ANALOG\FI-1302 \VALUE' 或 TagName = ' ANALOG\FI-1301 \VALUE' 或 TagName = ' ANALOG \PI -1401 \VALUE' 或 TagName = ' ANALOG\TI-1401 \VALUE' 或 TagName = ' ANALOG\TI-1402 \VALUE' 或 TagName = ' ANALOG\TI-1404 \ VALUE' 或 TagName = ' ANALOG\AI-1501 \ VALUE' 或 TagName = ' ANALOG \LI-1406 \ VALAL' 或 TagName = ' ANALOG \ FLOW-TOTAL-1201 \VALUE' 或 TagName = ' ANALOG\FLOW-TOTAL-1301\VALUE ' 或标签名= ' ANALOG \ FLOW-TOTAL-1302 \ VALUE' 或 TagName = ' ANALOG \ FLOW-TOTAL-1405 \ VALAL')MD PIVOT(最大值(VAL) FOR 标签名 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 但是显示空值的所有列的最大值(val) 但它们包含的行为包含值解决方案 对不起,但您的问题不明确。 我建议开始这里 [ ^ ]。 helloi have following querySELECT * 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') MDPIVOT(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]))PIVOTDATAbut max(val) for all columns showing null valuebut they actaully containing values 解决方案 Sorry, but your question is not clear.I'd suggest to start here[^]. 这篇关于枢轴查询没有任何聚合函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-12 01:58