Jump to content
Server Maintenance This Week. ×

Percentage with execute SQL


This topic is 3834 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi everybody,

 

i'm going to calculate a percentage with ExecuteSQL, but i believe my syntax is wrong.

 

i've 2 multiple field which show type and sale (total for type) as list, as in the picture.

 

Now i'd like to calculate a percentage on the total for each type.

 

Table are 2,

Customer where i've all customer information as name, address etc, and Type

and Invoice... 

 

for the multiple field called "Ricavi" (SALES in English) i used this:

 
ExecuteSQL("
SELECT SUM(A2.TOTAL) TOTAL
FROM CUSTOMERS A1
LEFT OUTER JOIN INVOICE A2 
ON A1.ID_CUSTOMER=A2.ID_CUSTOMER
GROUP BY A1.TYPE
";
"";""
)

 

If i write in the new calculated filed as follow it doesn't work:

 

ExecuteSQL("
SELECT SUM(A2.TOTAL) TOTAL *100 / (SELECT SUM (A2.TOTAL) From INVOICE A2)
FROM CUSTOMERS A1
LEFT OUTER JOIN INVOICE A2 
ON A1.ID_CUSTOMER=A2.ID_CUSTOMER
GROUP BY A1.TYPE
";
"";""
)

 

Who can HELP ME?

 

Thanks a lot

 

@

 

 

post-108850-0-36548500-1383393475_thumb.

Link to comment
Share on other sites

This topic is 3834 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.