我的表看起来像这样:
md5 other columns
098f6bcd4621d373cade4e832627b4f6
ad0234829205b9033196ba818f7a872b
ad0234829205b9033196ba818f7a872b
md5字段不是唯一的。
但我想只计算具有唯一md5的记录。我可以在sqlite中做到吗?
在上面的例子中,计数将是1(第一条记录)
答案 0 :(得分:1)
SELECT COUNT(*) FROM (
SELECT md5
FROM tablename
GROUP BY md5
HAVING COUNT(*)=1
) AS baseview
;
答案 1 :(得分:1)
您可以通过哈希对其进行分组:
SELECT COUNT(*) FROM (SELECT COUNT(*) from someTable GROUP BY md5 HAVING COUNT(*) = 1) AS sq;
答案 2 :(得分:1)
SELECT count(1) FROM (select distinct md5 from tablename) t