[AccessD] Add criteria to query

Kaup, Chester Chester_Kaup at kindermorgan.com
Wed Oct 9 09:05:36 CDT 2019


I have the following query that works fine. Thanks to some help from people here.

SELECT dbo_DSS_LastStatus.PID, dbo_DSS_LastStatus.Completion_Name, dbo_DSS_LastStatus.Status, [tbl Petra Current Status Copy].[Sym Code]
INTO [tbl Petra and DSS Status]
FROM (dbo_DSS_LastStatus INNER JOIN dbo_DSS_CompletionMaster ON dbo_DSS_LastStatus.PID = dbo_DSS_CompletionMaster.PID)
INNER JOIN [tbl Petra Current Status Copy] ON dbo_DSS_CompletionMaster.ParentPID = [tbl Petra Current Status Copy].[UWI (APINum)]
GROUP BY dbo_DSS_LastStatus.PID, dbo_DSS_LastStatus.Completion_Name, dbo_DSS_LastStatus.Status, [tbl Petra Current Status Copy].[Sym Code]
HAVING ((([tbl Petra Current Status Copy].[Sym Code]) Not Like "PA*" And ([tbl Petra Current Status Copy].[Sym Code])<>"P&A" And ([tbl Petra Current Status Copy].[Sym Code])<>"side"));

I then added criteria for Sym Code of  "infill". The issue is all records of Sym Code "infill" are being returned. Your assistance appreciated.

SELECT dbo_DSS_LastStatus.PID, dbo_DSS_LastStatus.Completion_Name, dbo_DSS_LastStatus.Status, [tbl Petra Current Status Copy].[Sym Code] INTO [tbl Petra and DSS Status]
FROM (dbo_DSS_LastStatus INNER JOIN dbo_DSS_CompletionMaster ON dbo_DSS_LastStatus.PID = dbo_DSS_CompletionMaster.PID) INNER JOIN [tbl Petra Current Status Copy] ON dbo_DSS_CompletionMaster.ParentPID = [tbl Petra Current Status Copy].[UWI (APINum)]
GROUP BY dbo_DSS_LastStatus.PID, dbo_DSS_LastStatus.Completion_Name, dbo_DSS_LastStatus.Status, [tbl Petra Current Status Copy].[Sym Code]
HAVING ((([tbl Petra Current Status Copy].[Sym Code]) Not Like "PA*" And ([tbl Petra Current Status Copy].[Sym Code])<>"P&A" And ([tbl Petra Current Status Copy].[Sym Code])<>"side")) OR (((dbo_DSS_LastStatus.Status)="TA" Or (dbo_DSS_LastStatus.Status)="P&A") AND (([tbl Petra Current Status Copy].[Sym Code])="infill"));



More information about the AccessD mailing list