Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我做这样的事情时:
SELECT AVG(Price) FROM Product WHERE ProductName = 'Shoe';
SQL 返回如下内容:6,5934348324242
6,5934348324242
一个有很多位数的平均数字。
是否可以在查询中执行某些操作,以便查询返回 2/3 位(例如:6,59)而不是 10 位以上的数字?
我在用MySql
MySql
您可以将其转换为小数:
SELECT cast(AVG(Price) as decimal(6, 2)) FROM Product WHERE ProductName = 'Shoe';