Kaup, Chester
Chester_Kaup at kindermorgan.com
Mon Dec 12 12:25:41 CST 2011
That is kind of what I was thinking. Trying to do something that cannot be done. Thanks for confirming it. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of McGillivray, Don Sent: Monday, December 12, 2011 11:34 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Append Query syntax error Missed that. You can't insert into "Count(A.PID)" of the destination table. Think about it . . . Remove the Count() from around A.PID. That should do it. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Monday, December 12, 2011 9:27 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Append Query syntax error I tried your suggestions ( I think correctly) and still get an insert into syntax error. The cursor goes to the "(" after count on the first line when the syntax error comes up. Thanks for the ideas. Here is how the sql reads now INSERT INTO [tbl Monthly Well Count] (Count(A.PID) AS [Active Flowing Count],EngArea) (SELECT DISTINCT A.PID, EngArea FROM [tbl Statuses During Prior Month] AS A WHERE(A.Status In ("FL","FM","FH"))); -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of McGillivray, Don Sent: Monday, December 12, 2011 10:57 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Append Query syntax error Try this: 1) Lose the FROM before your subquery. 2) Not sure whether you need the parentheses around your subquery. Access SQL may require it, but other flavors (e.g. Oracle) don't. 3) The GROUP BY clause was part of the main query - not the subquery - in the original. Take that out. HTH, Don -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Monday, December 12, 2011 8:18 AM To: Access Developers discussion and problem solving Subject: [AccessD] Append Query syntax error The following select query works great SELECT Count(A.PID) AS [Active Flowing Count],EngArea FROM (SELECT DISTINCT A.PID, EngArea FROM [tbl Statuses During Prior Month] AS A WHERE(A.Status In ("FL","FM","FH"))) Group by EngArea; When I tried to make it an append query I get a syntax error. I don't see the error. Maybe someone else can INSERT INTO [tbl Monthly Well Count](Count(A.PID) AS [Active Flowing Count],EngArea) FROM (SELECT DISTINCT A.PID, EngArea FROM [tbl Statuses During Prior Month] AS A WHERE(A.Status In ("FL","FM","FH"))) Group by EngArea; Thanks Chester Kaup Engineering Technician Kinder Morgan CO2 Company, LLP Office (432) 688-3797 FAX (432) 688-3799 No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com