1
是否可以在GROUP BY
select語句中使用LAST_VALUE
關鍵字?SQL Server 2014 LAST_VALUE GROUP BY
SELECT colA,
LAST_VALUE(colB)
OVER (PARTITION BY ... ORDER BY ... ROWS BETWEEN ...)
FROM MyTable
GROUP BY colA
是否可以在GROUP BY
select語句中使用LAST_VALUE
關鍵字?SQL Server 2014 LAST_VALUE GROUP BY
SELECT colA,
LAST_VALUE(colB)
OVER (PARTITION BY ... ORDER BY ... ROWS BETWEEN ...)
FROM MyTable
GROUP BY colA
我不認爲window
功能可用於group by
。可能是sub-select
會做這個工作
select colA,L_values
from
(
SELECT colA,
LAST_VALUE(colB)
OVER (PARTITION BY ... ORDER BY ... ROWS BETWEEN ...) L_Value
FROM MyTable
) a
group by colA,L_values
請更好地解釋你的問題,目前還不清楚你在問什麼。 – Tanner 2015-03-13 11:10:50
確保你不會因爲這個http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Mihai 2015-03-13 11:29:29