sql - 带有 SELECT 语句的尾随“000000000000003”
问题描述
我在数据库中有以下架构和数据:
Create table Scores (Id int, Score NUMBER(3,2))
Truncate table Scores
insert into Scores (Id, Score) values ('1', '3.5')
insert into Scores (Id, Score) values ('2', '3.65')
insert into Scores (Id, Score) values ('3', '4.0')
insert into Scores (Id, Score) values ('4', '3.85')
insert into Scores (Id, Score) values ('5', '4.0')
insert into Scores (Id, Score) values ('6', '3.65')
我写了以下查询:
SELECT Score, DENSE_RANK() OVER (ORDER BY Score DESC) AS Rank FROM Scores;
它适用于大多数结果。Scores
但有时我会在结尾0
和结尾得到值3
,例如:57.43000000000000003
.
有人可以解释为什么会这样吗?
更新:
解决这个问题: https ://leetcode.com/problems/rank-scores/
添加ROUND(Score, 2)
,它工作正常。但仍然不清楚尾随零。
解决方案
推荐阅读
- php - EasyAdmin:“无法转换属性路径 XY 的值:需要一个字符串。”
- html - 更改 html/css 中元素顺序的问题
- c# - 我应该使用临时数据库对象而不是 Web API 的会话吗?
- android - getActivity空异常警告?
- cmake - 为 Autotools 项目导出 CMake 目标
- azure - Azure Functions 发布
- python - 如何获得多个字典的最小/最大值?
- bluetooth-lowenergy - 无法读取未定义的属性“bluetoothGattService”
- python - 我是 python 脚本的新手。请问如何过滤并将行导出到新的文本文件
- internationalization - Github 页面:构建失败 => 如何调试?