Board index » delphi » Problem using calculated field

Problem using calculated field

hi there,

win95, D5.
I have three table, tbCustomer, tbOrder and tbOrdDetail, which have
master-detail relationship. Each of them has calculated field named TOTAL.
tbOrderTotal is the sum of tbOrdDetailTotal, and tbCustomerTotal is the sum
of tbOrderTotal.
I have tried using query something like: "SELECT OrderNo, SUM(Total) as
Total FROM OrdDetail WHERE OrderNo = :No GROUP BY OrderNo", but the query
return "Invalid field name. Total". The query succeeds only if I create
field TOTAL using DBD, but I think it will spent too much on harddisk space.
How do i have to do to get away from this situation?

Thanks

Agung Maryanto

 

Re:Problem using calculated field


I post this second copy because I didn't see first one appear in OE in 10
minutes.

hi there,

win95, D5.
I have three table, tbCustomer, tbOrder and tbOrdDetail, which have
master-detail relationship. Each of them has calculated field named TOTAL.
tbOrderTotal is the sum of tbOrdDetailTotal, and tbCustomerTotal is the sum
of tbOrderTotal.
I have tried using query something like: "SELECT OrderNo, SUM(Total) as
Total FROM OrdDetail WHERE OrderNo = :No GROUP BY OrderNo", but the query
return "Invalid field name. Total". The query succeeds only if I create
field TOTAL using DBD, but I think it will spent too much on harddisk space.
How do i have to do to get away from this situation?

Thanks

Agung Maryanto

Re:Problem using calculated field


I'm not sure, but I think it's a simple problem:
You already have a field "Total" on which you calc the sum. The you try to
give the result of the calculation the same name with the "AS Total"
statement. I think that causes the error. Why don't you give it another name
? Hmh... "AS sTotal" or something and try it again.

Bart Simpson

Other Threads