1

I have a table that has the following fields:

1- Name

2- Dept

3- DateWorked

5- Session

the table filled with data about people from different departments that worked on different date and different sessions (AM/PM). I want to count the number of sessions that all people in a specific dept worked. Please note that:

1- Several people work on a department.

2- Each person may work several sessions. (on different date)

3- I want to know thw number of session that any persion of a department worked. for example, it doesn't matter if on say 28/12/2012 AM, two person from sale department worked, It should be counted as one.

I maybe able to write access VBA code to do this, but I prefer a sql query to do this.

Can you please give me a clue how I can do this?

I am using Access 2003.

4

2 回答 2

0

例如,请给出一个创建表和一个日期。但我会托盘:

SELECT Dep, DateWorked, COUNT(*) as ammount FROM your_table GROUP BY DateWorked, Dep
于 2012-12-29T11:10:02.887 回答
0
select t1.Dept, count(*) from
(
    select distinct Dept, DateWorked, Session from t
) AS t1
group by t1.Dept;
于 2012-12-29T11:16:22.397 回答