我有這個表:的MS Access獲得平均時間
button_log
=======================================
|ID | table_no | transaction_datetime |
=======================================
| 1 | 1 | 22/07/2017 |
| 2 | 1 | 22/07/2017 |
| 3 | 1 | 22/07/2017 |
| 4 | 1 | 22/07/2017 |
service_time
===============================
|ID | table_no | service_time |
===============================
| 1 | 1 | 00:00:06 |
| 2 | 1 | 00:00:05 |
| 3 | 1 | 00:00:03 |
| 4 | 1 | 00:00:10 |
我有這個疑問:
select b.table_no, count(*) as total_call_count, sum(TimeValue(c.service_time) * 86400) as total_time from button_log b, service_time_log c where b.table_no = c.table_no and Format(b.transaction_datetime,""DD/MM/yyyy"") = '" & Date.Now.ToString("d") & "' group by b.table_no
,但我有這個結果
==========================================
|table_no | total_call_count | total_time|
==========================================
| 1 | 4 | 96 |
我期望的結果是:
==========================================
|table_no | total_call_count | total_time|
==========================================
| 1 | 4 | 24 |
我怎樣才能total_time總和每記錄一次?
你不想總和total_time,你希望該值只顯示一次?不要使用Sum,只要檢索total_time字段並將其包含在GROUP BY子句中。 – June7
@ June7但後來我會有4行作爲結果..我只需要1個結果。 –
好的,您是否更改了示例數據?我認爲他們都有相同的服務時間,我想知道它是否真正具有代表性。 – June7