Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 SQL Sum help?

Author  Topic 

MikeB
Constraint Violating Yak Guru

387 Posts

Posted - 2002-07-05 : 14:22:19
I am trying to get the sum of a field, I use c++, ADO, with a access database. Here is the Select statement I use:

csGetWeight.Format("SELECT SUM(Weight) AS [TotalWeight] FROM
ShippingLoadTable WHERE ShippingDate = #%s# AND ProjectNumber = '%s' AND LoadNumber = %d", csDate, m_csProjectNumber, nLoadNumber);


Does anyone see anything wrong with this?

Mike B

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-07-08 : 08:16:15
If you are using wildcard characters, you should use the "like" keyword instead of "=". Also, the wildcard character is Access is "*" instead of "%".


SELECT SUM(Weight) AS [TotalWeight]
FROM ShippingLoadTable
WHERE ShippingDate like #*s#
AND ProjectNumber like '*s' AND LoadNumber like *d", csDate, m_csProjectNumber, nLoadNumber);

Let me know if this doesn't work.

Jeremy


Go to Top of Page
   

- Advertisement -