Hi,
What does Transform do?
I have this query that is giving me the wrong data, I just can't figure out what's wrong:
i'm trying to figure out what's wrong with this query:
TRANSFORM Sum(tblSource.[A Pax]) AS Pax SELECT tblQtrHrs.QtrHrTime, 'A' AS
Bound FROM tblSource, tblQtrHrs WHERE ( (Not tblQtrHrs.QtrHrTime Is Null)
AND (IIf(Not tblSource.Format = "IATA",tblSource.[A Pax],1)>0) AND
(Nz([tblSource]![A Deleted],0)<>1) AND ((tblSource.[A Terminal] IN (1,2,3)
AND tblSource.[A Sect] in('D')) ) AND
((IIf([tblQtrHrs].[qtrHrTime]>=#23:15:0# And [tblSource].[A
Time]<#0:45:0#,DateAdd('d',1,[tblSource].[A Time]),[tblSource].[A
Time]))>=([tblQtrHrs].[QtrHrTime]) And
(IIf([tblQtrHrs].[qtrHrTime]>=#23:15:0# And [tblSource].[A
Time]<#0:45:0#,DateAdd('d',1,[tblSource].[A Time]),[tblSource].[A
Time]))<=DateAdd('s',59,DateAdd('n',59,[tblQtrHrs].[QtrHrTime]))) ) AND
((([tblSource].[Format]="ATB" and tblSource.Name='ATB_db-S05S02V6-Base
Case') or ([tblSource].[Format]="DAPS" and
tblSource.Name='ATB_db-S05S02V6-Base Case' and ([tblSource].[A
Date]+[tblSource].[A Time]>=#1/1/2000 4:00:00 AM# and [tblSource].[A
Date]+[tblSource].[A Time]<=#1/2/2000 4:00:00 AM#)) or
([tblSource].[Format] = "IA
TA" and tblSource.Name='ATB_db-S05S02V6-Base Case' and ([tblSource].[A
Date]+[tblSource].[A Time]>=dateadd("h",-4,#1/1/2000 4:00:00 AM#) and
[tblSource].[A Date]+[tblSource].[A Time]<=dateadd("h",-4,#1/2/2000 4:00:00
AM#)))) ) GROUP BY tblQtrHrs.QtrHrTime, 'A'PIVOT [tblSource]![Name] & '
Pax';
the result looks like this:..i've only shown the first few
entries...basically it looks at the flight schedule and group the flights by
quarter of an hour ..summing up the passenger numbers in each quarter
hour...
QtrHrTime Bound ATB_db-S05S02V6-Base Case Pax
5:15 A 297
5:30 A 502
5:45 A 962
6:00 A 1084
6:15 A 1298
6:30 A 1538
6:45 A 1424
7:00 A 1636
7:15 A 1303
here's the source table:
tblSource Name Format Airline ACType Terminal Seats A Fl # A Sect A Date A
Time A Pax A Route A Deleted D Fl # D Sect D Date D Time D Pax D Route D
Deleted Load A Terminal D Terminal
ATB_db-S05S02V6-Base Case ATB EGF EM3 3 37 4747 T
7:42:00 PM 24 BOS 0
0 0 3 3
sample of another source table:
tblQtrHrs QtrHrNum QtrHrTime
0 0:00
15 0:15
30 0:30
45 0:45
100 1:00
the problem is that if you look at the first table where at 5:15 there are
297 passengers, the time should actually be 6:00
I've been trying to play around with it...but don't really know why it'd put
it into the wrong time slot~~~
What does Transform do?
I have this query that is giving me the wrong data, I just can't figure out what's wrong:
i'm trying to figure out what's wrong with this query:
TRANSFORM Sum(tblSource.[A Pax]) AS Pax SELECT tblQtrHrs.QtrHrTime, 'A' AS
Bound FROM tblSource, tblQtrHrs WHERE ( (Not tblQtrHrs.QtrHrTime Is Null)
AND (IIf(Not tblSource.Format = "IATA",tblSource.[A Pax],1)>0) AND
(Nz([tblSource]![A Deleted],0)<>1) AND ((tblSource.[A Terminal] IN (1,2,3)
AND tblSource.[A Sect] in('D')) ) AND
((IIf([tblQtrHrs].[qtrHrTime]>=#23:15:0# And [tblSource].[A
Time]<#0:45:0#,DateAdd('d',1,[tblSource].[A Time]),[tblSource].[A
Time]))>=([tblQtrHrs].[QtrHrTime]) And
(IIf([tblQtrHrs].[qtrHrTime]>=#23:15:0# And [tblSource].[A
Time]<#0:45:0#,DateAdd('d',1,[tblSource].[A Time]),[tblSource].[A
Time]))<=DateAdd('s',59,DateAdd('n',59,[tblQtrHrs].[QtrHrTime]))) ) AND
((([tblSource].[Format]="ATB" and tblSource.Name='ATB_db-S05S02V6-Base
Case') or ([tblSource].[Format]="DAPS" and
tblSource.Name='ATB_db-S05S02V6-Base Case' and ([tblSource].[A
Date]+[tblSource].[A Time]>=#1/1/2000 4:00:00 AM# and [tblSource].[A
Date]+[tblSource].[A Time]<=#1/2/2000 4:00:00 AM#)) or
([tblSource].[Format] = "IA
TA" and tblSource.Name='ATB_db-S05S02V6-Base Case' and ([tblSource].[A
Date]+[tblSource].[A Time]>=dateadd("h",-4,#1/1/2000 4:00:00 AM#) and
[tblSource].[A Date]+[tblSource].[A Time]<=dateadd("h",-4,#1/2/2000 4:00:00
AM#)))) ) GROUP BY tblQtrHrs.QtrHrTime, 'A'PIVOT [tblSource]![Name] & '
Pax';
the result looks like this:..i've only shown the first few
entries...basically it looks at the flight schedule and group the flights by
quarter of an hour ..summing up the passenger numbers in each quarter
hour...
QtrHrTime Bound ATB_db-S05S02V6-Base Case Pax
5:15 A 297
5:30 A 502
5:45 A 962
6:00 A 1084
6:15 A 1298
6:30 A 1538
6:45 A 1424
7:00 A 1636
7:15 A 1303
here's the source table:
tblSource Name Format Airline ACType Terminal Seats A Fl # A Sect A Date A
Time A Pax A Route A Deleted D Fl # D Sect D Date D Time D Pax D Route D
Deleted Load A Terminal D Terminal
ATB_db-S05S02V6-Base Case ATB EGF EM3 3 37 4747 T
7:42:00 PM 24 BOS 0
0 0 3 3
sample of another source table:
tblQtrHrs QtrHrNum QtrHrTime
0 0:00
15 0:15
30 0:30
45 0:45
100 1:00
the problem is that if you look at the first table where at 5:15 there are
297 passengers, the time should actually be 6:00
I've been trying to play around with it...but don't really know why it'd put
it into the wrong time slot~~~