MySQL\u4e2d\u7684\u56db\u5428\u5165\u51fd\u6570\u662fROUND()\u51fd\u6570\u3002ROUND()\u51fd\u6570\u7528\u4e8e\u5c06\u4e00\u4e2a\u6570\u5b57\u8fdb\u884c\u56db\u5428\u5165\uff0c\u53ef\u4ee5\u6307\u5b9a\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570\u3002\n\n\u8bed\u6cd5\uff1a\nROUND(number, decimal_places)\n\n\u53c2\u6570\u8bf4\u660e\uff1a\n- number\uff1a\u9700\u8981\u8fdb\u884c\u56db\u5428\u5165\u7684\u6570\u5b57\u3002\n- decimal_places\uff1a\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570\u3002\u53ef\u4ee5\u4e3a\u6b63\u6570\u8868\u793a\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570\uff0c\u4e3a\u8d1f\u6570\u8868\u793a\u56db\u5428\u5165\u5230\u6574\u6570\u4f4d\u3002\n\n\u793a\u4f8b\uff1a\n1. \u5c06\u6570\u5b573.141592653589793\u8fdb\u884c\u56db\u5428\u5165\u4fdd\u7559\u4e24\u4f4d\u5c0f\u6570\uff1a\nSELECT ROUND(3.141592653589793, 2);\n\n\u7ed3\u679c\uff1a3.14\n\n2. \u5c06\u6570\u5b573.141592653589793\u8fdb\u884c\u56db\u5428\u5165\u4fdd\u7559\u4e00\u4f4d\u5c0f\u6570\uff1a\nSELECT ROUND(3.141592653589793, 1);\n\n\u7ed3\u679c\uff1a3.1\n\n3. \u5c06\u6570\u5b573.141592653589793\u8fdb\u884c\u56db\u5428\u5165\u5230\u6574\u6570\u4f4d\uff1a\nSELECT ROUND(3.141592653589793, 0);\n\n\u7ed3\u679c\uff1a3

MySQL ROUND() 函数:数字四舍五入指南

原文地址: https://www.cveoy.top/t/topic/qbHP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录