R
RWhittet
Hi, I have built two different queries, one works, and the second does not
work correctly. I am attempting to pull all records from one table, and only
the records in the second table which are the first entry of the day. I have
puzzled through this several times and am unable to figure out why it's not
working correctly. The problem I am having is that the second query is not
pulling the first record of the day, where the first query will pull that
record every time. Any help is most appreciated. I am pasting the query
which isn't working first, and the second is the one which does work. Thanks!
SELECT [South Plant Filter Runtimes].Date, [South Plant Filter
Runtimes].[Filter #], [South Plant Filter Runtimes].Time, [South Plant Filter
Runtimes].Type, [South Plant Filter Runtimes].Hours, [South Plant Filter
Runtimes].Comments, [South Plant Filter Runtimes].[Failure Step], [South
Plant Filter Runtimes].Headloss, [South Plant Filter Runtimes].[Filter Flow
Rate], First([Plant Flows].Date) AS FirstOfDate, First([Plant Flows].[South
Plant Flow]) AS [FirstOfSouth Plant Flow], First([Plant Flows].[Filter 14
Status]) AS [FirstOfFilter 14 Status], First([Plant Flows].[Filter 15
Status]) AS [FirstOfFilter 15 Status], First([Plant Flows].[Filter 16
Status]) AS [FirstOfFilter 16 Status], First([Plant Flows].[Filter 17
Status]) AS [FirstOfFilter 17 Status], First([Plant Flows].[Filter 18
Status]) AS [FirstOfFilter 18 Status], First([Plant Flows].[Filter 19
Status]) AS [FirstOfFilter 19 Status], First([Plant Flows].[Filter 20
Status]) AS [FirstOfFilter 20 Status], First([Plant Flows].[Filter 21
Status]) AS [FirstOfFilter 21 Status], First([Plant Flows].[Filter 22
Status]) AS [FirstOfFilter 22 Status], First([Plant Flows].[Filter 23
Status]) AS [FirstOfFilter 23 Status], First([Plant Flows].[West 5 MG Tank
Level]) AS [FirstOfWest 5 MG Tank Level], First([Plant Flows].[East 5 MG Tank
Level]) AS [FirstOfEast 5 MG Tank Level]
FROM [Plant Flows] RIGHT JOIN [South Plant Filter Runtimes] ON [Plant
Flows].Day = [South Plant Filter Runtimes].Date
GROUP BY [South Plant Filter Runtimes].Date, [South Plant Filter
Runtimes].[Filter #], [South Plant Filter Runtimes].Time, [South Plant Filter
Runtimes].Type, [South Plant Filter Runtimes].Hours, [South Plant Filter
Runtimes].Comments, [South Plant Filter Runtimes].[Failure Step], [South
Plant Filter Runtimes].Headloss, [South Plant Filter Runtimes].[Filter Flow
Rate]
HAVING ((([South Plant Filter Runtimes].Date)>=[Forms]![Date
Dialog]![Beginning Date] And ([South Plant Filter
Runtimes].Date)<=[Forms]![Date Dialog 2]![Ending Date]) AND (([South Plant
Filter Runtimes].[Filter #]) Is Not Null));
SELECT [North Plant Filter Runtimes].Date, [North Plant Filter
Runtimes].[Filter #], [North Plant Filter Runtimes].Time, [North Plant Filter
Runtimes].Hours, [North Plant Filter Runtimes].Comments, [North Plant Filter
Runtimes].[Failure Step], [North Plant Filter Runtimes].[Headloss Trip
Setpoint], [North Plant Filter Runtimes].[Filter Flow Rate], First([Plant
Flows].Date) AS FirstOfDate, First([Plant Flows].[Filter 3 Status]) AS
[FirstOfFilter 3 Status], First([Plant Flows].[Filter 4 Status]) AS
[FirstOfFilter 4 Status], First([Plant Flows].[Filter 5 Status]) AS
[FirstOfFilter 5 Status], First([Plant Flows].[Filter 7 Status]) AS
[FirstOfFilter 7 Status], First([Plant Flows].[Filter 8 Status]) AS
[FirstOfFilter 8 Status], First([Plant Flows].[West 5 MG Tank Level]) AS
[FirstOfWest 5 MG Tank Level], First([Plant Flows].[East 5 MG Tank Level]) AS
[FirstOfEast 5 MG Tank Level], First([Plant Flows].[Filter 6 Status]) AS
[FirstOfFilter 6 Status], First([Plant Flows].[North Plant Flow]) AS
[FirstOfNorth Plant Flow], [North Plant Filter Runtimes].Type
FROM [Plant Flows] RIGHT JOIN [North Plant Filter Runtimes] ON [Plant
Flows].Day = [North Plant Filter Runtimes].Date
GROUP BY [North Plant Filter Runtimes].Date, [North Plant Filter
Runtimes].[Filter #], [North Plant Filter Runtimes].Time, [North Plant Filter
Runtimes].Hours, [North Plant Filter Runtimes].Comments, [North Plant Filter
Runtimes].[Failure Step], [North Plant Filter Runtimes].[Headloss Trip
Setpoint], [North Plant Filter Runtimes].[Filter Flow Rate], [North Plant
Filter Runtimes].Type
HAVING ((([North Plant Filter Runtimes].Date)>=[Forms]![Date
Dialog]![Beginning Date] And ([North Plant Filter
Runtimes].Date)<=[Forms]![Date Dialog 2]![Ending Date]));
work correctly. I am attempting to pull all records from one table, and only
the records in the second table which are the first entry of the day. I have
puzzled through this several times and am unable to figure out why it's not
working correctly. The problem I am having is that the second query is not
pulling the first record of the day, where the first query will pull that
record every time. Any help is most appreciated. I am pasting the query
which isn't working first, and the second is the one which does work. Thanks!
SELECT [South Plant Filter Runtimes].Date, [South Plant Filter
Runtimes].[Filter #], [South Plant Filter Runtimes].Time, [South Plant Filter
Runtimes].Type, [South Plant Filter Runtimes].Hours, [South Plant Filter
Runtimes].Comments, [South Plant Filter Runtimes].[Failure Step], [South
Plant Filter Runtimes].Headloss, [South Plant Filter Runtimes].[Filter Flow
Rate], First([Plant Flows].Date) AS FirstOfDate, First([Plant Flows].[South
Plant Flow]) AS [FirstOfSouth Plant Flow], First([Plant Flows].[Filter 14
Status]) AS [FirstOfFilter 14 Status], First([Plant Flows].[Filter 15
Status]) AS [FirstOfFilter 15 Status], First([Plant Flows].[Filter 16
Status]) AS [FirstOfFilter 16 Status], First([Plant Flows].[Filter 17
Status]) AS [FirstOfFilter 17 Status], First([Plant Flows].[Filter 18
Status]) AS [FirstOfFilter 18 Status], First([Plant Flows].[Filter 19
Status]) AS [FirstOfFilter 19 Status], First([Plant Flows].[Filter 20
Status]) AS [FirstOfFilter 20 Status], First([Plant Flows].[Filter 21
Status]) AS [FirstOfFilter 21 Status], First([Plant Flows].[Filter 22
Status]) AS [FirstOfFilter 22 Status], First([Plant Flows].[Filter 23
Status]) AS [FirstOfFilter 23 Status], First([Plant Flows].[West 5 MG Tank
Level]) AS [FirstOfWest 5 MG Tank Level], First([Plant Flows].[East 5 MG Tank
Level]) AS [FirstOfEast 5 MG Tank Level]
FROM [Plant Flows] RIGHT JOIN [South Plant Filter Runtimes] ON [Plant
Flows].Day = [South Plant Filter Runtimes].Date
GROUP BY [South Plant Filter Runtimes].Date, [South Plant Filter
Runtimes].[Filter #], [South Plant Filter Runtimes].Time, [South Plant Filter
Runtimes].Type, [South Plant Filter Runtimes].Hours, [South Plant Filter
Runtimes].Comments, [South Plant Filter Runtimes].[Failure Step], [South
Plant Filter Runtimes].Headloss, [South Plant Filter Runtimes].[Filter Flow
Rate]
HAVING ((([South Plant Filter Runtimes].Date)>=[Forms]![Date
Dialog]![Beginning Date] And ([South Plant Filter
Runtimes].Date)<=[Forms]![Date Dialog 2]![Ending Date]) AND (([South Plant
Filter Runtimes].[Filter #]) Is Not Null));
SELECT [North Plant Filter Runtimes].Date, [North Plant Filter
Runtimes].[Filter #], [North Plant Filter Runtimes].Time, [North Plant Filter
Runtimes].Hours, [North Plant Filter Runtimes].Comments, [North Plant Filter
Runtimes].[Failure Step], [North Plant Filter Runtimes].[Headloss Trip
Setpoint], [North Plant Filter Runtimes].[Filter Flow Rate], First([Plant
Flows].Date) AS FirstOfDate, First([Plant Flows].[Filter 3 Status]) AS
[FirstOfFilter 3 Status], First([Plant Flows].[Filter 4 Status]) AS
[FirstOfFilter 4 Status], First([Plant Flows].[Filter 5 Status]) AS
[FirstOfFilter 5 Status], First([Plant Flows].[Filter 7 Status]) AS
[FirstOfFilter 7 Status], First([Plant Flows].[Filter 8 Status]) AS
[FirstOfFilter 8 Status], First([Plant Flows].[West 5 MG Tank Level]) AS
[FirstOfWest 5 MG Tank Level], First([Plant Flows].[East 5 MG Tank Level]) AS
[FirstOfEast 5 MG Tank Level], First([Plant Flows].[Filter 6 Status]) AS
[FirstOfFilter 6 Status], First([Plant Flows].[North Plant Flow]) AS
[FirstOfNorth Plant Flow], [North Plant Filter Runtimes].Type
FROM [Plant Flows] RIGHT JOIN [North Plant Filter Runtimes] ON [Plant
Flows].Day = [North Plant Filter Runtimes].Date
GROUP BY [North Plant Filter Runtimes].Date, [North Plant Filter
Runtimes].[Filter #], [North Plant Filter Runtimes].Time, [North Plant Filter
Runtimes].Hours, [North Plant Filter Runtimes].Comments, [North Plant Filter
Runtimes].[Failure Step], [North Plant Filter Runtimes].[Headloss Trip
Setpoint], [North Plant Filter Runtimes].[Filter Flow Rate], [North Plant
Filter Runtimes].Type
HAVING ((([North Plant Filter Runtimes].Date)>=[Forms]![Date
Dialog]![Beginning Date] And ([North Plant Filter
Runtimes].Date)<=[Forms]![Date Dialog 2]![Ending Date]));