Hi,
I need some help trying to figure this out. Please see the example tables below and 2 separate queries. Is there a way to combine them together?
fh
ID Field1 Field2 Field3 Time1
1 In Null U1 2011-12-01
1 Out In U1 2011-12-02
1 Wait Out U2 2011-12-03
2 Out In U1 2011-12-02
3 In Wait U3 2011-12-05
m
ID Col1 Col2 Col3
1 xxx xxx xxx
2 bbb xxx xxx
3 aaa xxx xxx
4 xxx xxx xxx
May be a bit confusing, but any help would be appreciated. Thanks!
D
I need some help trying to figure this out. Please see the example tables below and 2 separate queries. Is there a way to combine them together?
fh
ID Field1 Field2 Field3 Time1
1 In Null U1 2011-12-01
1 Out In U1 2011-12-02
1 Wait Out U2 2011-12-03
2 Out In U1 2011-12-02
3 In Wait U3 2011-12-05
m
ID Col1 Col2 Col3
1 xxx xxx xxx
2 bbb xxx xxx
3 aaa xxx xxx
4 xxx xxx xxx
Code:
select m.ID, m.Col1, m.Col2, m.Col3, fh.Field3
From Master9 as m
Inner Join Master10 as fh
On m.ID = fh.ID
Where fh.Field1 = Wait
Code:
select fh.ID,
DateDiff(minute,
Min(Case When fh.Field1 = 'In' Then fh.Time1 End),
Min(Case When fh.Field1 = 'Out' Then fh.Time1 End))
As TimeDiff
From Master10 as fh
Inner Join Master 9 as m
On fh.ID = m.ID
Where m.Col1 = 'xxx'
Group By fh.ID
Having DateDiff(minute,
Min(Case When fh.Field1 = 'In' Then fh.Time1 End),
Min(Case When fh.Field1 = 'Out' Then fh.Time1 End)) > 0
Order By fh.ID
May be a bit confusing, but any help would be appreciated. Thanks!
D