如何在 SQL 中选择按用户分组的当天的第一个条目
我环顾四周,但无法完全掌握从 MS Access 2000 表中提取数据所需的 SQL 查询问题的完整答案。
下面是表 [Time Sub] 的示例:
**CLIENT_ID, DATE_ENTERED, CODE, MINUTES**
11111, 5/12/2008 3:50:52 PM, M, 38
11111, 5/12/2008 2:55:50 PM, M, 2
11714, 5/13/2008 1:15:32 PM, M, 28
11111, 5/13/2008 6:15:12 PM, W, 11
11112, 5/12/2008 2:50:52 PM, M, 89
11112, 5/12/2008 5:10:52 PM, M, 9
91112, 5/14/2008 1:10:52 PM, L, 96
11112, 5/12/2008 5:11:52 PM, M, 12
我需要为每个客户端选择每天的第一个条目,该条目不是代码 L 或 W。
我知道这可以在 SQL 语句中完成,但我就是做不到弄清楚如何。我可以接近,但永远无法想出正确的输出。
任何帮助表示赞赏。
谢谢, 麦克风
I've looked around and can't quite grasp the whole answer to this SQL query question needed to extract data from an MS Access 2000 table.
Here's an example of what the table [Time Sub] looks like:
**CLIENT_ID, DATE_ENTERED, CODE, MINUTES**
11111, 5/12/2008 3:50:52 PM, M, 38
11111, 5/12/2008 2:55:50 PM, M, 2
11714, 5/13/2008 1:15:32 PM, M, 28
11111, 5/13/2008 6:15:12 PM, W, 11
11112, 5/12/2008 2:50:52 PM, M, 89
11112, 5/12/2008 5:10:52 PM, M, 9
91112, 5/14/2008 1:10:52 PM, L, 96
11112, 5/12/2008 5:11:52 PM, M, 12
I need to select the first entry of each day per client that's NOT code L or W.
I know this can be done in a SQL statement, but I just can't figure out how. I can get close, but never come up with the right output.
Any help is appreciated.
Thanks,
Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试一试。我想这就是你所要求的。
Give this a spin. I think it's what you're asking for.
我从未使用过 MS Access,因此您可能需要纠正 SQL 差异:
I have never used MS Access, so you may have to correct for SQL differences:
我在使用了其他人已经做过的事情后发现了这一点。这是我想出的:
I figured it out after using pieces of what everyone else had already done. Here's what I came up with: