タイムスタンプで分単位でグループ化しながら合計と平均を求めるクエリがあります。ただし、タイムスタンプのSAME分が異なる時間帯にある場合、その行データは表示されません。以下はクエリと出力、個々の行は次のとおりです。GroupBy Datepart関数にデータがありません
NumCardsPassed ProcessingTime ProcessingDate
10 4 2016-08-29 11:13:44.000
1 0 2016-08-29 11:49:43.000
2 1 2016-08-29 12:19:42.000
ここでは、すべてのグループを除いた個々の行を示します。 12:13と22:13のタイムスタンプが上記のクエリでは欠落している方法に気付くことDATEPARTのでしたがって、基本的
NumCardsPassed ProcessingTime processingdate
1 2 2016-08-29 11:13:44.000
1 0 2016-08-29 11:49:43.000
8 10 2016-08-29 12:13:44.000
1 3 2016-08-29 12:19:42.000
1 0 2016-08-29 22:13:47.000
Select sum(numcardspassed) as "NumCardsPassed",
avg(processingtime) as "ProcessingTime", min(ProcessingDate) as "ProcessingDate"
From orderprocessormetrics
where ProcessingDate >= '8/27/2016' and ProcessingDate < '8/30/2016' and PreprocessorType = 'SOP' and numcardsPassed > 0 and clientid = 6820
Group by DatePart(minute, orderprocessormetrics.processingdate)
order by processingdate
(代わりに10に等しくなければならない上記NumCardsPassed、それは10で通過午前11時13 numcardsにこれを追加しました)時間に関係なく、すべての行を同じ分数でグループ化しています。時間と日付を考慮する方法はありますか?分だけではありません。私は数分ではなく、秒またはミリ秒でグループ化するためにそれでも必要です。