类型转换问题
在下面的查询中,1/2 的答案始终为零,而它应该是 0.5。你能告诉我如何将两个 int 列转换为 float/double 吗?
SELECT 1/2, total, sb_ondate, likes
FROM (
SELECT sb_ondate, COUNT(*) AS total,
STRFTIME("%w",sb_ondate) AS weekDay,
COUNT(CASE WHEN sb_reaction = 'like' THEN sb_id END) AS likes
FROM diet
GROUP BY weekDay) AS f;
谢谢。
In the following query, the answer of 1/2 is always zero while it should be 0.5. Can you please tell me how to convert the two int columns into float/double?
SELECT 1/2, total, sb_ondate, likes
FROM (
SELECT sb_ondate, COUNT(*) AS total,
STRFTIME("%w",sb_ondate) AS weekDay,
COUNT(CASE WHEN sb_reaction = 'like' THEN sb_id END) AS likes
FROM diet
GROUP BY weekDay) AS f;
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将两个除数之一转换为实数:
交互式 Python 会话示例:
Cast
one of the two divisors as areal
:Sample interactive Python session:
将
.0
添加到常量之一:Add
.0
to one of the constants: