W
|
WilliamBDevClub member 2/24/2020 |
138.92 / 12 = 11.57666666666667 |
![]() |
Admin 2/24/2020 |
@BillyB, |
![]() |
lefty author 2/24/2020 |
@BillyB, is spot on, the result of this division is 11.57(6). If you want it to be consistent you need to round it up or down right in the SQL query. Check round() function: https://www.mysqltut...ns/mysql-round/
|
W
|
WilliamBDevClub member 2/24/2020 |
This all makes sense but if it indeed should round to 11.58 , it would make the case cost $138.96 which now becomes the wrong case cost instead of $138.92. Which in turn throws off all the calculations of other fields. . Then again you have a point as if I multiply 11.57 12 = 138.84 is also wrong but so is 11.58 12 = 138.96. hmmm never ran into this before I guess?? I did not show the whole query but here is another part of it SELECT flditemID ,branddesc ,size ,fldcommodity ,division_name ,minbottle ,case_cost ,bottle_post ,case_post ,packed_qty ,( case_cost /packed_qty ) AS bottle_cost ,((minbottle - (case_cost / packed_qty)) / minbottle) 100 AS gross_profit ,IF( size = '750ML', ((case_cost/packed_qty)/25.36), 0) AS 750OZ ,IF( size = '750ML', ((case_cost/packed_qty)/25.366),0) AS 750Glass ,IF( size = '750ML', Round(((case_cost/packed_qty)/25.366)4), 0) AS 750Sell , // This is suggested sell price by trade standardsIF( size = '750ML', (((case_cost/packed_qty)/25.366)4), 0)- IF(size = '750ML',((case_cost/packed_qty)/25.366),0) AS 750profit ,IF( size = '1.5L', ((case_cost/packed_qty)/50.72), 0) AS 15OZ ,IF( size = '1.5L', ((case_cost/packed_qty)/50.726), 0) AS 15Glass ,IF( size = '1.5L', Round(((case_cost/packed_qty)/50.726)4), 0) AS 15Sell ,IF( size = '1.5L', (((case_cost/packed_qty)/50.726)4), 0)- (IF(size = '1.5L',((case_cost/packed_qty)/50.726), 0)) AS 15profit ,IF ( size = '750ML' , ((case_cost/packed_qty)/25.366)/ (((case_cost/packed_qty)/25.366)4),0) 100 As Glassper,IF ( size = '1.5L' , ((case_cost/packed_qty)/50.726)/ (((case_cost/packed_qty)/50.726)4),0) * 100 As GlCstper,UPC FROM supplier_data WHERE ( size = '750ML' OR size = '1.5L') AND (fldcommodity = 'Sparkling Wine/Champ' OR fldcommodity = 'Still Wine' OR fldcommodity = 'Fortified Wine')This is premature as I just saw this reply and I must be misunderstanding something . Will have to investigate.and the other a third party mobile application result in $11.57.??? _I pull the import in a CSV file , from SAP and it runs Mysqlimport.exe from a batch file and ( Task Scheduler ) and imports into MySQL which in turn PHPrunner picks it up. But PHPrunner is running my query as I show above with the incorrect result. _I need for the query to match what a ( MAJOR ERP SYSTEM SAP )Shows as 11.57. How can I achieve this?
|
![]() |
lefty author 2/24/2020 |
I'm not sure but maybe you are looking for this. There are a few examples that will not round in this post. https://stackoverflo...ound-numbers-up
|
![]() |
Admin 2/25/2020 |
I still recommend doing it in MySQL to avoid any potential inconsistencies. If you need to round it down use TRUNCATE() function: |
![]() |
lefty author 2/25/2020 |
I still recommend doing it in MySQL to avoid any potential inconsistencies. If you need to round it down use TRUNCATE() function: https://dev.mysql.co...nction_truncate
|