2017-04-26 63 views
0

我有一個表Vocab,我想找到總行和重複數的數量,這是我想找到兩個不同的查詢總數之間的差額SQL

(SELECT COUNT(*) FROM Vocab) - (SELECT COUNT(*) FROM Vocab GROUP BY Word) 的代碼,但它返回我錯誤Unexpected token. (near "-" at position 29),我怎樣才能實現我的目標?

+0

你說的重複的總數是什麼意思? –

+0

@GordonLinoff同行 –

回答

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; 
+0

感謝你的家園! –

相關問題