如何查询数据库以查找只有一名员工工作的日期 [英] How to query database to find date where only one employee worked

查看:61
本文介绍了如何查询数据库以查找只有一名员工工作的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




这里是我正在使用的数据示例..


AdminDB.Roster


日期名称

03/10/2010 Bob

03/10/2010 Bob

03/10 / 2010 Dan

03/10/2010 Bob


04/10/2010 Bob

04/10/2010鲍勃

04/10/2010 Bob

04/10/2010鲍勃

04/10/2010 Bob

04 / 10/2010鲍勃


05/10/2010 Bob

05/10/2010 Bob

05/10/2010 Dan

05/10/2010 Dan


基本上每天有很多参赛作品代表班次和轮班工作人员。

我想要做的是知道任何一天只有一个人工作所有轮班,记住可能有'到'04 / 10 / 2010-鲍勃'(例如)的3到10个条目/>

例如计算不同日期的行数;计算不同日期和名称的行数;告诉我两个计数结果相同的日期。


所以结果应该是''04 / 10/2010'',因为那天只有一个人工作了总班次。


这有意义吗?有人可以帮忙吗?


还有。 ''date''和'name''是单独的字段。而且我只想知道日期,如果是Bob,他们都是轮班工作。


谢谢你

解决方案

< blockquote>是的它确实...


试试这个:

展开 | 选择 | 换行 | 行号


ck9663,


非常感谢您的回复,但只有在任何日期只有一个''bob''条目时才会有效 - 请参阅我的数据,在一个日期有'6 bob''有6个条目...


因为你说你是寻找只有1名员工的日期。尝试删除where子句。它会给你每个日期的员工数量。


祝你好运!!!


~~ CK

Hi,

here is as example of the data I''m working with..

AdminDB.Roster

Date Name
03/10/2010 Bob
03/10/2010 Bob
03/10/2010 Dan
03/10/2010 Bob

04/10/2010 Bob
04/10/2010 Bob
04/10/2010 Bob
04/10/2010 Bob
04/10/2010 Bob
04/10/2010 Bob

05/10/2010 Bob
05/10/2010 Bob
05/10/2010 Dan
05/10/2010 Dan

Basically there are numerous entries per day which represent shifts and who worked those shifts.

What I want to do is know any day where only one person worked ALL shifts, keeping in mind there could be between 3 and 10 entries of ''04/10/2010- Bob'' (E.g)

E.g. Count the rows for distinct date; count the rows for distinct date AND name; show me the date where both counts are the same result.

So the result should be ''04/10/2010'' because only one person worked the total amount of shifts that day.

Does this make sense? can anyone please help?

ALSO. ''date'' and ''name'' are seperate fields. And I only want to know the date if it was ''Bob'' who worked all shifts.

THANK YOU

解决方案

Yes it does...

Try this:

Expand|Select|Wrap|Line Numbers


ck9663,

thank you very much for your response, but this will only work if there is only one entry for ''bob'' on any date - see my data, there are 6 entries for ''bob'' on the one date...


Because you said you''re looking for dates with only 1 employee worked. Try removing the where clause. It''ll give you the count of employee per date.


Good Luck!!!

~~ CK


这篇关于如何查询数据库以查找只有一名员工工作的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆