Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何将sql查询舍入到较低的整数_Mysql_Sql_Select_Floating Point_Rounding - Fatal编程技术网

Mysql 如何将sql查询舍入到较低的整数

Mysql 如何将sql查询舍入到较低的整数,mysql,sql,select,floating-point,rounding,Mysql,Sql,Select,Floating Point,Rounding,例如,我有一个查询: select (select size from acc where acc_id = 1)/(select count(m_id) from m_acc JOIN dns ON dns.dns_id = m_acc.dns_id where acc_id = 1)*1000000; 查询结果: 3333333333.3330 我想去 3333333333 我不需要四舍五入到上整数。我要四舍五入来降低整数。我试着这样做: select floor (select s

例如,我有一个查询:

select (select size from acc where acc_id = 1)/(select count(m_id) from m_acc  JOIN dns ON dns.dns_id = m_acc.dns_id where acc_id = 1)*1000000;
查询结果:

3333333333.3330
我想去

3333333333
我不需要四舍五入到上整数。我要四舍五入来降低整数。我试着这样做:

select floor (select size from acc where acc_id = 1)/(select count(m_id) from m_acc  JOIN dns ON dns.dns_id = m_acc.dns_id where acc_id = 1)*1000000;
但结果我收到了:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'size from acc where acc_id = 1)/(select coun' at line 1
请告诉我哪里有错误?

使用。试试这个:

select FLOOR
(
    (select size from acc where acc_id = 1)
    /
    (select count(m_id) from m_acc  JOIN dns ON dns.dns_id = m_acc.dns_id where acc_id = 1)
    *
    1000000
);
floor()
是一个函数,因此需要将参数放在括号中