Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Timesheet Query - Most common free time for all

Author  Topic 

jwijaya
Starting Member

1 Post

Posted - 2012-02-12 : 21:46:42
Hi everyone, I really need a help with my simple access database. I am using MS Access and here is my table:

Emp_ID M0800 M0830 M0900 M0930 M1000 M1030 M1100 M1130 M1200
000001 No____No____No____Yes___Yes___No____No____Yes___Yes
000002 No____No____Yes___Yes___Yes___No____Yes___No____Yes
000003 No____No____Yes___No____Yes___No____Yes___Yes___No
000004 No____No____No____No____Yes___No____No____No____No
000005 No____No____Yes___Yes___No____No____Yes___Yes___Yes
000006 No____No____Yes___Yes___Yes___No____Yes___Yes___Yes

M0800: Monday at 08:00AM
M1130: Monday at 11:30AM
Yes: Is where the employee has a scheduled work.
No : Free time.
Emp_ID: Employee ID

If we look at the table above, we can easily tell that all employees are free from M0800-M0830 and at M1030. But I would like to run a query that simply compare all columns and return the most common free time for everybody ;It will return either just the column name with all "No" value, or it will return the list of all employees with columns that have no "Yes" value like:

Emp_ID M0800 M0830 M1030
000001 No____No____No
000002 No____No____No
000003 No____No____No
000004 No____No____No
000005 No____No____No
000006 No____No____No

I do apologize if the table design is so poor due to limited knowledge of database that I have. Please let me know if there is a work around if my query and expected return are impossible to run.

Thank you so much in advance!

John

John

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-02-12 : 21:53:18
Please post in "MS Access" forum http://www.sqlteam.com/forums/forum.asp?FORUM_ID=3

Or you might get a solution for SQL 2005


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -