|period_id | date_from | date_to |
|----------|------------|---------------|
| 1 | 16/11/2018 | 17/11/2018 |
|---------------------------------------|
表sessionrange
| sessionrange_id | session | session_from | session_to |
|-----------------|---------|--------------|------------|
| 1 | A | 04:00:00 | 05:10:00 |
| 2 | B | 12:00:00 | 12:45:00 |
| 3 | C | 15:00:00 | 15:30:00 |
| 4 | D | 18:00:00 | 18:30:00 |
| 5 | E | 19:00:00 | 19:45:00 |
--------------------------------------------------------
表timsetup
| period_id | sessionrange_id |
|-----------|-----------------|
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
------------------------------
表checktime
|userid | tapping_time |
|---------|----------------------|
|2120 | 16/11/2018 04:20:04 |
|2120 | 16/11/2018 12:26:06 |
|2120 | 16/11/2018 12:26:10 |
|2120 | 16/11/2018 15:35:21 |
|2120 | 16/11/2018 18:29:11 |
|2120 | 16/11/2018 19:40:10 |
|2120 | 17/11/2018 05:05:15 |
|2120 | 17/11/2018 12:11:53 |
|2120 | 17/11/2015 15:24:42 |
|2121 | 16/11/2015 04:18:47 |
|2121 | 16/11/2015 12:21:27 |
|2121 | 16/11/2015 15:45:30 |
|2121 | 16/11/2015 15:45:38 |
|2121 | 16/11/2015 18:27:37 |
|2121 | 16/11/2015 19:32:15 |
|2121 | 17/11/2015 05:09:08 |
|2121 | 17/11/2015 12:24:08 |
|2121 | 17/11/2015 15:13:08 |
|2121 | 17/11/2015 19:32:08 |
|2121 | 17/11/2015 19:32:15 |
表,其中包含来自指纹扫描仪的数据SELECT userid, Format(datevalue, 'yyyy-mm-dd') AS d, Format(TimeValue(Min(t.CHECKTIME))) As timevalue, session
FROM (
SELECT session_from, session_to, date_from, date_to, session
FROM ((timesetup i LEFT JOIN dateperiod d ON i.period_id = d.period_id)
LEFT JOIN sessionrange q ON i.sessionrange_id = q.sessionrange_id)
) As s
INNER JOIN (SELECT Format(DateValue(CHECKTIME)) As datevalue, Format(TimeValue(CHECKTIME)) As tapping, u.userid, CHECKTIME
FROM CHECKINOUT c
LEFT JOIN USERINFO u ON c.userid = u.userid
WHERE (Format(DateValue(c.CHECKTIME), 'yyyy-mm-dd') BETWEEN '$from' AND '$to')) t ON ((t.datevalue BETWEEN s.date_from AND s.date_to) AND (t.tapping BETWEEN s.session_from AND s.session_to))
GROUP BY userid, datevalue, session, u.Badgenumber
ORDER BY userid, datevalue, Format(TimeValue(Min(t.CHECKTIME)))
当前查询已经按会话从某个日期的一个用户的多个轻敲时间中进行过滤,并从不在会话范围中的检查时间进行过滤
| userid | d | tapping_on | session |
|---------|------------|------------|---------|
| 2120 | 16/11/2018 | 04:20:04 | A |
| 2120 | 16/11/2018 | 12:26:06 | B |
| 2120 | 16/11/2018 | 18:29:11 | D |
| 2120 | 16/11/2018 | 19:40:10 | E |
| 2120 | 16/11/2018 | 05:05:15 | A |
| 2120 | 17/11/2018 | 12:11:53 | B |
| 2120 | 17/11/2018 | 15:24:42 | C |
| 2121 | 16/11/2015 | 04:18:47 | A |
| 2121 | 16/11/2015 | 12:21:27 | B |
| 2121 | 16/11/2015 | 18:27:37 | D |
| 2121 | 16/11/2015 | 19:32:15 | E |
| 2121 | 17/11/2015 | 05:09:08 | A |
| 2121 | 17/11/2015 | 12:24:08 | B |
| 2121 | 17/11/2015 | 15:13:08 | C |
| 2121 | 17/11/2015 | 19:32:08 | E |
|---------------------------------------------|
------------------------------------------------------------------------------------
| userid | date | A | B | C | D | E
|--------|--------------|-----------|-----------|-----------|-----------|---------- |
| 2120 | 16/10/2018 | 04:20:04 | 12:26:06 | NULL | 18:29:11 | 19:40:10 |
| 2120 | 17/10/2018 | 05:05:15 | 12:11:53 | 15:24:42 | NULL | NULL |
| 2121 | 16/10/2018 | 04:18:47 | 12:21:27 | NULL | 18:27:37 | 19:32:15 |
| 2121 | 17/10/2018 | 05:09:08 | 12:24:08 | 15:13:08 | NULL | 19:32:08 |
------------------------------------------------------------------------------------
但是我需要分组的不同结果
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new Scaffold(
body: Row(
children: <Widget>[
Flexible(
child: Column(
children: <Widget>[
Container(
child: TextField(),
)
//container
],
))
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
));
}
}
过滤是相同的,但分组方式不同(按用户ID,日期,会话)。 如何自定义当前查询以在Access女士中产生期望的结果?
答案 0 :(得分:0)
一种方法是在您选择的语句中执行5种情况。您可以做类似的事情
(Case When session_from > 04:00:00 and session_to < 05:10:00 Then tapping_on End) A
(Case When session_from > 05:00:00 and session_to < 06:10:00 Then tapping_on End) B
等
本质上,您先创建列,然后在其中显示所需的任何值,在这种情况下,轻按[on]。