Kamis, 23 Maret 2017

Re: [MS_AccessPros] ODBC - Call falled. Not Sure why!

 

Bill-


You need to read SQL Queries for Mere Mortals!  😃  Use a HAVING clause to filter aggregates.

From Chapter 14:

"List for each customer and order date the customer's full name and the total cost of
items ordered that is greater than $1,000."

SELECT Customers.CustFirstName || ' ' ||
Customers.CustLastName AS CustFullName,
Orders.OrderDate,
SUM(Order_Details.QuotedPrice *
Order_Details.QuantityOrdered) AS TotalCost
FROM (Customers
INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID)
INNER JOIN Order_Details
ON Orders.OrderNumber =
Order_Details.OrderNumber
GROUP BY Customers.CustFirstName,
Customers.CustLastName, Orders.OrderDate
HAVING SUM(Order_Details.QuotedPrice *
Order_Details.QuantityOrdered) > 1000;

Note that the HAVING clause further filters the result based on an aggregate.  (ANSI SQL Syntax)

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Mar 23, 2017, at 8:22 PM, 'Bill Mosca' wrmosca@comcast.net [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



I stand corrected, John. So why is a HAVING clause ever necessary if it is that inefficient? 
 
Regards,
Bill
 
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] 
Sent: Wednesday, March 22, 2017 2:33 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] ODBC - Call falled. Not Sure why!
 
  

Umm.  I don't think so, Bill.  The WHERE clause filters rows first, THEN applies the grouping.  Putting it in the HAVING clause causes it to GROUP the entire table first, then filter it. 

 
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)
 

 

 
On Mar 22, 2017, at 10:20 PM, Bill Mosca wrmosca@comcast.net [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 


Art - you might also try moving the WHERE clause to a HAVING clause. It might improve performance.
 
SELECT Count(ApplicantID) AS Applications
, Year(AppReceivedDate) AS Year_of_Application
FROM DBO.tblApplication
GROUP BY Year(AppReceivedDate);
HAVING Year(AppReceivedDate)>=2008
 
 
 
Regards,
Bill Mosca

From: "Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS Access Professionals" <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, March 22, 2017 1:57:11 PM
Subject: Re: [MS_AccessPros] ODBC - Call falled. Not Sure why!
 
 
 
John, 
Perfect, thank you. 

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070


"Anyone who claimed that old age had brought them patience was either lying or senile."   
 
 
 
 
 
 

From: "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com> 
Sent: Wednesday, March 22, 2017 2:43 PM
Subject: Re: [MS_AccessPros] ODBC - Call falled. Not Sure why!

 
  
You could try a passthrough query:
 
SELECT Count(ApplicantID) AS  Applications, Year(AppReceivedDate) AS Year_of_Application
FROM DBO.tblApplication
WHERE Year(AppReceivedDate)>=2008
GROUP BY Year(AppReceivedDate);
 
 
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)
 

 

 
On Mar 22, 2017, at 9:27 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 


 
 
Yes it is a SQL Server 2008. 

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070


"Anyone who claimed that old age had brought them patience was either lying or senile."   




 


From: "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com> 
Sent: Wednesday, March 22, 2017 1:50 PM
Subject: Re: [MS_AccessPros] ODBC - Call falled. Not Sure why!
 
Art-
 
And what database stores that table?  SQL Server?
 
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)
 

 

 
On Mar 22, 2017, at 8:42 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 


 
 
Yes it is. tblApplication is a linked table. 

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070


"Anyone who claimed that old age had brought them patience was either lying or senile."   




 


From: "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com> 
Sent: Wednesday, March 22, 2017 1:41 PM
Subject: Re: [MS_AccessPros] ODBC - Call falled. Not Sure why!
 
Art-
 
ODBC implies you're connecting to a back end like SQL Server.  Is that the case?  Is tblApplication a linked table?
 
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)
 

 

 
On Mar 22, 2017, at 8:16 PM, dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 


 
I have the following query...


SELECT Count([tblApplication].[ApplicantID]) AS  Applications, Year([tblApplication].[AppReceivedDate]) AS [Year of Application]
FROM tblApplication
WHERE (((Year([tblApplication].[AppReceivedDate]))>=2008))
GROUP BY Year([tblApplication].[AppReceivedDate]);


I get ODBC-call failed... error. I am not sure what's wrong with it.


Thank you ,


Art Lorenzini






 
 
 
 

 

 

 
 
 
 

 

 

 
 
 
 
 
 
 

 

 



__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (14)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar