Click here to Skip to main content
15,923,197 members
Home / Discussions / Database
   

Database

 
QuestionReporting Service: "Remote name cannot be resolved" Pin
devvvy24-Mar-06 17:23
devvvy24-Mar-06 17:23 
Questionsql sort problem Pin
shabonaa24-Mar-06 7:37
shabonaa24-Mar-06 7:37 
AnswerRe: sql sort problem Pin
Dave Kreskowiak24-Mar-06 8:18
mveDave Kreskowiak24-Mar-06 8:18 
GeneralRe: sql sort problem Pin
shabonaa24-Mar-06 10:28
shabonaa24-Mar-06 10:28 
GeneralRe: sql sort problem Pin
Rob Graham24-Mar-06 11:40
Rob Graham24-Mar-06 11:40 
GeneralRe: sql sort problem Pin
Colin Angus Mackay24-Mar-06 12:41
Colin Angus Mackay24-Mar-06 12:41 
GeneralRe: sql sort problem Pin
shabonaa24-Mar-06 13:07
shabonaa24-Mar-06 13:07 
QuestionQuery Is Required? Pin
majidbhutta24-Mar-06 6:00
majidbhutta24-Mar-06 6:00 
Beolw is the tables Structure and dummy data used in Access database
Employee
========
EmpId(Pk int) EName(Text) DeptId(Fk int)
1 Rashid 1
2 Kashif 2
3 Black 1
4 White 2
5 Brown 2


Department
==========
DeptId(Pk int) DName(Text)
1 Labor
2 Secret
3 Production
4 Purchase

Attendance
==========
AttId(Pk Int) EmpId(Fk int) In/Out_Time(Datetime) Direction
1 2 2/5/2006 6:37:02 PM 1 // 1 for IN, 0 For OUT
2 2 2/5/2006 8:37:02 PM 0
3 2 2/5/2006 8:50:00 PM 1
4 1 2/5/2006 8:51:00 PM 1
5 1 2/5/2006 9:37:02 PM 0
6 2 2/5/2006 9:40:02 PM 0
7 3 2/5/2006 6:37:04 PM 1
8 4 2/5/2006 6:37:06 PM 1
9 5 2/5/2006 6:37:08 PM 1
10 5 2/5/2006 8:40:02 PM 0
11 4 2/5/2006 8:40:40 PM 0
12 3 2/5/2006 8:40:50 PM 0

13 2 3/5/2006 6:37:02 PM 1
14 2 3/5/2006 8:37:02 PM 0
15 2 3/5/2006 8:50:00 PM 1
16 1 3/5/2006 8:51:00 PM 1
17 1 3/5/2006 9:37:02 PM 0
18 2 3/5/2006 9:40:02 PM 0
19 3 3/5/2006 6:37:04 PM 1
20 4 3/5/2006 6:37:06 PM 1
21 5 3/5/2006 6:37:08 PM 1
22 5 3/5/2006 8:40:02 PM 0
23 4 3/5/2006 8:40:40 PM 0
24 3 3/5/2006 8:40:50 PM 0


And so on the attendance data for whole month.

What i need is an optimized efficient query that takes a Start_date(DateTime) as an input parameter and returns me the

Attendance data of all Employees for one week. Means starting from startdate and ending at startdate+6 days in the following

format

EName DName IstDay 2ndDay 3rdDay 4thDay 5thDay 6thDay 7thDay



Where as IstDay to 7thDay Columns contains the value for total Working hrs at that day as

IstDay = [{Value of In/Out_Time Column for Max(AttId) When Direction=0}-
{Value of In/Out_Time Column for Min(AttId) When Direction=1}
Where DatePart(d,In/Out_Time)=DatePart(d,@Start_Time) for any EMpId]

2ndDay = [{Value of In/Out_Time Column for Max(AttId) When Direction=0}-
{Value of In/Out_Time Column for Min(AttId) When Direction=1}
Where DatePart(d,In/Out_Time)=DatePart(d,@Start_Time+1 Day) for any EMpId]

3rdDay = [{Value of In/Out_Time Column for Max(AttId) When Direction=0}-
{Value of In/Out_Time Column for Min(AttId) When Direction=1}
Where DatePart(d,In/Out_Time)=DatePart(d,@Start_Time+2 Days) for any EMpId]

4thDay = [{Value of In/Out_Time Column for Max(AttId) When Direction=0}-
{Value of In/Out_Time Column for Min(AttId) When Direction=1}
Where DatePart(d,In/Out_Time)=DatePart(d,@Start_Time+3 days) for any EMpId]

And so on upto 7th day.

Now i m in need of an efficient query that returns me the required above result set.
NOTE
====

I am using Access 2000 database so i need a query or anything else that may give me the required output in Access database

Thnx in Advance





QuestionPlease help totally lost on syntax Pin
MeterMan24-Mar-06 4:09
MeterMan24-Mar-06 4:09 
AnswerRe: Please help totally lost on syntax Pin
Michael Potter24-Mar-06 4:21
Michael Potter24-Mar-06 4:21 
GeneralRe: Please help totally lost on syntax Pin
MeterMan24-Mar-06 4:36
MeterMan24-Mar-06 4:36 
GeneralRe: Please help totally lost on syntax Pin
Michael Potter24-Mar-06 4:50
Michael Potter24-Mar-06 4:50 
GeneralRe: Please help totally lost on syntax Pin
MeterMan24-Mar-06 4:43
MeterMan24-Mar-06 4:43 
GeneralRe: Please help totally lost on syntax Pin
Michael Potter24-Mar-06 4:52
Michael Potter24-Mar-06 4:52 
GeneralRe: Please help totally lost on syntax Pin
MeterMan24-Mar-06 6:25
MeterMan24-Mar-06 6:25 
GeneralRe: Please help totally lost on syntax Pin
Michael Potter24-Mar-06 8:39
Michael Potter24-Mar-06 8:39 
GeneralRe: Please help totally lost on syntax Pin
MeterMan25-Mar-06 12:43
MeterMan25-Mar-06 12:43 
QuestionDelete Procedure Pin
shapper24-Mar-06 3:28
shapper24-Mar-06 3:28 
AnswerRe: Delete Procedure Pin
Michael Potter24-Mar-06 4:10
Michael Potter24-Mar-06 4:10 
QuestionSQL Server over Virtual Private Network Pin
StyleGuide24-Mar-06 0:08
StyleGuide24-Mar-06 0:08 
AnswerRe: SQL Server over Virtual Private Network Pin
Luis Alonso Ramos24-Mar-06 5:45
Luis Alonso Ramos24-Mar-06 5:45 
GeneralRe: SQL Server over Virtual Private Network Pin
StyleGuide26-Mar-06 6:21
StyleGuide26-Mar-06 6:21 
GeneralRe: SQL Server over Virtual Private Network Pin
Luis Alonso Ramos26-Mar-06 17:47
Luis Alonso Ramos26-Mar-06 17:47 
QuestionLogin ID and Password Pin
mrkeivan23-Mar-06 11:00
mrkeivan23-Mar-06 11:00 
AnswerRe: Login ID and Password Pin
Krisky23-Mar-06 17:39
Krisky23-Mar-06 17:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.