如何按秒數分組時間(MS Access) - Conflation

[英]How to group time by period of seconds (MS Access) - Conflation


I work with a large dataset that I need to conflate within a specified time window.
For instance, some rows from the dataset :

我使用一個大型數據集,我需要在指定的時間窗口內進行混淆。例如,數據集中的某些行:

symbol LAST_TRADE_TIME       CUR    BID     OFFER   VOLUME
DBK     2010-12-05 11:34:57   38    37.99   38      0
DBK     2010-12-05 11:34:57   38    37.99   38      0
DBK     2010-12-05 11:34:57   38    37.99   38      100
DBK     2010-12-05 11:34:58   38    37.99   38.005  0

What I intend to do retrieve a small number of rows (time slices). Each of them represent a period of 300 seconds:

我打算做什么檢索少量行(時間片)。它們中的每一個代表300秒的時間段:

SELECT Min(LAST_TRADE_TIME) AS ConflatedDate, Min(CUR) 
FROM MYTABLE
GROUP BY DateDiff("s",@StartDate,LAST_TRADE_TIME)/300;

I should get a date and a CUR every 300 seconds

我應該每300秒獲得一個日期和一個CUR

If the use of datadiff does the job in sql server, in Ms ACCESS it returns total non sense to me.

如果使用datadiff在sql server中執行該作業,則在ACCESS中,它會向我返回完全無意義。

ConflatedDate Expr1001 12/5/2010 9:34:56 AM 38.2 12/5/2010 9:34:57 AM 38.2 12/5/2010 9:34:58 AM 38.2 12/5/2010 9:35:08 AM 38.2 12/5/2010 9:35:13 AM 38.19 12/5/2010 9:35:14 AM 38.19 12/5/2010 9:35:16 AM 38.19 12/5/2010 9:35:18 AM 38.2

ConflatedDate Expr1001 12/5/2010 9:34:56 AM 38.2 12/5/2010 9:34:57 AM 38.2 12/5/2010 9:34:58 AM 38.2 12/5/2010 9:35:08 AM 38.2 12/5/2010 9:35:13 AM 38.19 12/5/2010 9:35:14 AM 38.19 12/5/2010 9:35:16 AM 38.19 12/5/2010 9:35:18 AM 38.2

As you can see above, no group by is done on time.
Can someone help me here and tell what is wrong with this query in MS ACCESS? Or what to do to group by period?

如您所見,沒有按時完成分組。有人可以在這里幫助我,並告訴MS ACCESS中此查詢有什么問題嗎?或者按期分組怎么辦?

Many many thx
Jerome

許多人傑羅姆

1 个解决方案

#1


0  

You could do this for some fixed intervals:

您可以按固定的時間間隔執行此操作:

SELECT 
    CDate(Int(LAST_TRADE_TIME * 86400 / 300) / 86400 * 300)) AS ConflatedDate, 
    Min(CUR) As MinCur
FROM 
    MYTABLE
GROUP BY 
    CDate(Int(LAST_TRADE_TIME * 86400 / 300) / 86400 * 300))

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/09/30/72592bd9d7fde8ae8467e4784005ee0.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com