Jump to content
Henry Olive

FB-3,09 Getting Avg Percent of an Invoice

Recommended Posts

Good Day,

My S.Proc result like below

ID...LINENO..DOCNO....ITEMCODE....QTY...COST........SELL.....UNITPROFIT...TOTALPROFIT...UPERCENTAGE

1..............1...........100............AA....................1..... 10,00......12,00..................2,00.....................2,00...........  20,00

1..............2...........100............BB..................10..... 10,00......15,00..................5,00...................50,00...........  50,00

I calculated UnitPercentage above,

What is the general approach to get an Invoice's Total Profit Percentage ?

Like  (All Items Total Sell - All Items Total Cost) * 100 / All Items Total Cost ?

Thank You
 

Share this post


Link to post

No, no and no. Don't read the instructions!
I don't know if you want to know: If you do not divide by not an integer, then you have to retype. E.g.
CAST (1/3 AS DOUBLEPRECISSION) AS RESULT

Otherwise, the result will be Integer.

Share this post


Link to post
3 minutes ago, Stano said:

No, no and no. Don't read the instructions!
I don't know if you want to know: If you do not divide by not an integer, then you have to retype. E.g.
CAST (1/3 AS DOUBLEPRECISSION) AS RESULT 

Otherwise, the result will be Integer.

This will evaluate to zero:

SELECT CAST (1/3 AS DOUBLE PRECISION) AS RESULT FROM rdb$database

 

This will ealuate to 0.333333333333333333:

SELECT CAST (1 AS DOUBLE PRECISION) / 3 AS RESULT FROM rdb$database

 

But original question is about something else (probably windowing functions).

Share this post


Link to post

Gross margin as a percentage:

 

Gross Margin % = (Revenue – Cost of Goods Sold) / Revenue * 100

 

(Sell - Cost) / Sell * 100  

Share this post


Link to post

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

×