Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Sum Function Question

Status
Not open for further replies.

rixx

IS-IT--Management
May 20, 2002
15
US
I am trying to understand a SQL statement created by someone else. The Sql statement built is the following:

INSERT INTO Table2 ( Division, Customer_Number, Customer_Name, Invoice_Number, Invoice_Date, Net_Invoice_Amount, Freight_amount, Invoice_Amount) SELECT Table1.[Division], Table1.[CustomerNumber], [AR1_CustomerMaster].[CustomerName], Table1.[InvoiceNumber], Table1.[InvoiceDate], sum(Table1.[NonTaxableSalesAmount]), sum(Table1.[FrghtAmount]), sum(Table1.[FrghtAmount] + Table1.[NonTaxableSalesAmount] + Table1.[TaxableSalesAmount] + + Table1.[SalesTaxAmount]) FROM Table1 WHERE Table1.[InvoiceDate]= #DateFromInputBox#

My question is: Does the + + do anything or is it just a typo? It doesn't seem to affect the query, but I don't know what a "++" in the sum function does (or if it really does anything). Any help would be appreciated.

Thanks in advance,

rixx
 
I don't believe this is anything special other than a typo as you suggest. As a test, run it and see what the value is. Then take it out and run it to see if the value changes. I did that here and there was no difference.

Post back if you have further questions.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Thanks, Bob. I didn't see a difference either but I don't know SQL well enough to know if a ++ operator did something special.

Regards,

rixx
 
I was thinking. Becuase this is a query built by someone else there may be a field that is missing in the Sum function. You see I could see how a programmer(as I've done it myself) was typing and cutting and pasting in field names and may have deleted a field name out between two plus(+) signes and forgot to put one back in. So, check the logic of the Sum function and make sure that all of the fields to be added together in the sum are included.

Just a thought.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top