SQL查询报告我认为使用最小汇总以及操作员过滤的最小值是错误的最小值
我正在参加Coursera的SQL课程,这个问题在练习测验中提出了
“不包括0.00美元,最低每两周一周的高薪率是多少(请在您的答案中包括美元标志和小数点)?
现在我得到了正确的答案(返回$ 100.00)
SELECT
min(Biweekly_High_Rate)
FROM
salary_range_by_job_classification
WHERE Biweekly_High_Rate <> '$0.00'
但是,当我从同一表中查询选择 *时,我可以看到,至少在回收的行中,有一个$ 15.00的值,为什么不小于$ 100.00。返回$ 15.00?
I am taking an SQL course on coursera and this question came up on a practice quiz
"Excluding $0.00, what is the minimum bi-weekly high rate of pay (please include the dollar sign and decimal point in your answer)?
Now I got the right answer (Which returned $100.00) using
SELECT
min(Biweekly_High_Rate)
FROM
salary_range_by_job_classification
WHERE Biweekly_High_Rate <> '$0.00'
however, when I query using SELECT * from the same table, I can see that, at least in the rows retrieved, that there is a value of $15.00 which is less than $100.00. Why is it not returning $15.00? table snip of SELECT * FROM salary_range_by_job_classification
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议删除美元标志,然后将结果字符串转换为小数额。还输入十进制数量作为限制参数(
0.00
),因此您要比较两个数字,而不是两个字符串。这应该导致更多的期望:看看情况如何。如果您比较两个字符串,则使用
min
聚合要求(我认为)(我认为)第一个值字母。I would recommend removing the dollar sign and converting the resultant string to a decimal amount. Enter a decimal amount as your limiting parameter (
0.00
) as well, so you are comparing two numbers, not two strings. This should result in something more expected:See how that goes. If you compare two strings, you are asking for (I think) the first value alphabetically by using the
MIN
aggregation.您可以尝试一下。
You can try this.