我想通過使用以下查詢來獲取RANK
。我 不知道我到底在哪裏。 任何人都可以幫助我嗎?沒有得到Rank()分區的適當等級按DateTime
SELECT ID,CMNo,PLat,PLon,RDTime
,RANK() OVER (PARTITION BY CMNo,PLat,PLon,RDTime ORDER BY RDTime) Ranks
FROM tblMAEH WITH(NOLOCK)
WHERE CMNo = 69
AND RDTime BETWEEN '2014-10-19 00:00:00.000' AND '2014-10-20 23:59:59.997'
CREATE TABLE #test (id INT,CMNo INT,PLat NUMERIC(22, 6),Plon NUMERIC(22, 6),RDTime DATETIME)
INSERT INTO #test VALUES (8630,69,19.08491,72.83919,'21 oct 2014 14:38:13')
INSERT INTO #test VALUES (8631,69,19.08491,72.83919,'22 oct 2014 18:38:13')
INSERT INTO #test VALUES (8632,69,19.08491,72.83919,'20 oct 2014 14:39:13')
INSERT INTO #test VALUES (8633,69,19.08491,72.83919,'20 oct 2014 14:38:13')
SELECT ID,CMNo,PLat,PLon,RDTime,Rank()OVER (PARTITION BY CMNo, PLat, PLon, RDTime Order BY RDTime) Ranks
FROM #test WITH(NOLOCK)
WHERE CMNo = 69
AND RDTime BETWEEN '2014-10-19 00:00:00.000' AND '2014-10-25 23:59:59.997'
drop table #test
添加tblMAEH表的數據。 – 2014-10-30 10:27:54
其實輸出中有什麼問題。你需要什麼產出? – 2014-10-31 07:24:53
即使有你的例子,我也沒有太多的東西想要弄清你想要達到的目標。你可以嘗試編輯這個問題,並告訴我們你想要做什麼,以及*期望的輸出是什麼? – 2014-10-31 07:27:08