我正在尝试返回funny
我的 sqlite3 数据库中字段中前 10 个值的记录。我使用了以下查询:
SELECT * FROM ngrams
ORDER BY funny DESC
LIMIT 10;
funny
这将返回按字段降序排序的 10 条记录。但是,结果似乎只是fun < 10的前十个记录。这不是我想要的,我不确定我是怎么弄错的。作为记录,下面的查询返回 ~3,700,所以这些肯定不是我想要的前十条记录。
SELECT Count(*) FROM ngrams
WHERE funny > 10;
如何返回前十个funny
值的记录?
列名是ngram
, funny
, useful
, cool
, ngcount
.
输出:
sqlite> SELECT * FROM ngrams ORDER BY funny DESC LIMIT 10;
jetta| 9.914530| 5.726496| 6.367521| 117
emblem| 9.900000| 3.800000| 4.300000| 10
bt's| 9.875000| 11.375000| 10.625000| 8
dear phoenix| 9.857143| 8.285714| 7.857143| 7
look alikes| 9.857143| 7.428571| 6.428571| 7
alikes| 9.857143| 7.428571| 6.428571| 7
years im| 9.833333| 9.500000| 10.000000| 6
waaa| 9.833333| 8.000000| 7.000000| 6
earth do| 9.833333| 5.833333| 6.166667| 6
still full i| 9.833333| 7.500000| 8.000000| 6
sqlite> SELECT Count(*) FROM ngrams WHERE funny > 10;
3718
sqlite> SELECT * FROM ngrams WHERE ngram = 'megaphone';
megaphone| 14.777778| 10.555556| 10.555556| 9
sqlite> SELECT * FROM (
...> SELECT * FROM ngrams
...> ORDER BY funny DESC
...> ) topfunny LIMIT 10;
jetta| 9.914530| 5.726496| 6.367521| 117
emblem| 9.900000| 3.800000| 4.300000| 10
bt's| 9.875000| 11.375000| 10.625000| 8
dear phoenix| 9.857143| 8.285714| 7.857143| 7
look alikes| 9.857143| 7.428571| 6.428571| 7
alikes| 9.857143| 7.428571| 6.428571| 7
years im| 9.833333| 9.500000| 10.000000| 6
waaa| 9.833333| 8.000000| 7.000000| 6
earth do| 9.833333| 5.833333| 6.166667| 6
still full i| 9.833333| 7.500000| 8.000000| 6
sqlite>