我有這樣的SQL的MS SQL Server 2008中:追加模式這個SQL
WITH CTE AS (
SELECT e_id,
scale,
ROW_NUMBER() OVER(PARTITION BY e_id ORDER BY scale ASC) AS rn,
COUNT(scale) OVER(PARTITION BY e_id) AS cn
FROM waypoint.dbo.ScoreMaster
WHERE scale IS NOT NULL
)
SELECT e_id,
cast(AVG (cast(scale as decimal(5,2))) as decimal(5,3)) as [AVG],
cast (STDEV(cast(scale as decimal(5,1))) as decimal(5,3)) as [STDDEV],
AVG(CASE WHEN 2 * rn - cn BETWEEN 0 AND 2 THEN
scale END) AS FinancialMedian,
MAX(CASE WHEN 2 * rn - cn BETWEEN 0 AND 2 THEN
scale END) AS StatisticalMedian
from CTE
GROUP BY e_id
,我想補充的模式。 我一直在嘗試不同的想法,但沒有任何工程尚未...
你怎麼想的時候剛好有存在雙峯樣品(兩種模式),您的SQL表現在使用
MAX(co.sn)
?何時有兩種以上的模式? – kurast 2010-01-11 19:45:45