我有一个表Vocab
,我想找到总行数和重复数,这是我试过的代码
(SELECT COUNT(*) FROM Vocab) - (SELECT COUNT(*) FROM Vocab GROUP BY Word)
但它给我一个错误Unexpected token. (near "-" at position 29)
,我怎样才能实现我的目标?
答案 0 :(得分:3)
我认为你想要count(distinct)
和一些算术:
select count(*) as total_words,
count(distinct word) as total_distinct_words,
(count(*) - count(distinct word)) as must_be_duplicated
from Vocab;