我有一个具有数据时间和个人身份的表,我想在其中查找每天时间之间的时差并在SQL中求平均值。
输入表
+---------------------+----------+--------+
| Datetime | Identity | Type |
+---------------------+----------+--------+
| 28/08/2019 4:00:00 | ABC | Entry |
| 28/08/2019 14:00:00 | ABC | Exit |
| 29/08/2019 6:00:00 | ABC | Entry |
| 29/08/2019 6:10:00 | ABC | Exit |
| 30/08/2019 8:00:00 | ABC | Entry |
| 30/08/2019 17:00:00 | ABC | Exit |
+---------------------+----------+--------+
是否可以使用SQL中的以下数据创建另一个表?
+------------+----------+-----------+
| Date | Identity | Time(Min) |
+------------+----------+-----------+
| 28/08/2019 | ABC | 600 |
| 29/08/2019 | ABC | 10 |
| 30/08/2019 | ABC | 540 |
+------------+----------+-----------+
谢谢。
答案 0 :(得分:1)
您可以在下面尝试-适用于mysql
{
"author": "Robin Sharma",
"data": [
{
"translation": "en",
"content": "foo",
"unwanted_content": "huyu1",
},
],
}
或sql服务器-
select cast(datetime as date),
TIMESTAMPDIFF(MINUTE,min(case when Type='Entry' then datetime end),
max(case when Type='Exit' then datetime end))
from tablename
group by cast(datetime as date)
答案 1 :(得分:0)
我认为这应该可以在SQL Server中满足您的需求:
assistive_technologies=org.GNOME.Accessibility.AtkWrapper