0

It is showing Sum(with table name) is not valid. Kindly help:

Modws.DisplayDataGrid(dgvClosingBalance, 
                      "Select 
                           Invoice.Customer, Invoice.Sum(Total), 
                           RptTempTable.Sum(INVOICETOTAL), RptTempTable.Sum(CNTOTAL), 
                           RptTempTable.Sum(DEBITTOTAL), RptTempTable.Sum(RECEIPTTOTAL) 
                       From Invoice 
                       inner join RptTempTable on Invoice.Customer = RptTempTable.Customer")
4
  • Whats the exact error? what is the data type of the field your trying to SUM Commented Nov 18, 2014 at 9:36
  • all is decimal data type..i want to show the sum of all from 2 different tables in a grid view Commented Nov 18, 2014 at 9:37
  • 1
    There is no group by in your statement. Also: which DBMS are you using? Postgres? Oracle? Commented Nov 18, 2014 at 9:37
  • im using mysql...so i must add group by customer? Commented Nov 18, 2014 at 9:38

1 Answer 1

1

RptTempTable.Sum(INVOICETOTAL) should be Sum(RptTempTable.INVOICETOTAL)

The same goes for the other calls to sum()

The table prefix belongs to the column name not the function call.


MySQL will accept this invalid SQL and will return "inderminate" (aka "random") values instead.

To understand the implications of MySQL's "loose" (aka "sloppy") group by implementation you might want to read these articles:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.