admin管理员组文章数量:1313121
If we have the following set of data
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 values(1,1);
INSERT INTO t1 values(1,0);
And run the query
SELECT
IIF(b > 0, a / b, NULL) AS c
FROM t1
ORDER BY b DESC
We get the c
column as a numeric field and all is happy with the world. However, if I reverse the order, the first field is NULL
, and the column is now a STRING
.
SELECT
IIF(b > 0, a / b, NULL) AS c
FROM t1
ORDER BY b ASC
I can use 0
instead of NULL
in the expression, which solves the problem of the column type, but alters the result of the query.
Is there a way I can still have NULL
values, but the column is interpreted as a REAL
or INT
where the first record is NULL
?
本文标签:
版权声明:本文标题:SQLite calculated fields that should be Floats are Strings when calculation is NULL for the first record - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741934263a2405757.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论