Henry Olive 5 Posted April 9, 2022 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
Stano 143 Posted April 9, 2022 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
Vandrovnik 214 Posted April 9, 2022 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
weirdo12 19 Posted April 19, 2022 Gross margin as a percentage: Gross Margin % = (Revenue – Cost of Goods Sold) / Revenue * 100 (Sell - Cost) / Sell * 100 Share this post Link to post