仅计算Postgres DB中元素的特定子集

时间:2022-06-24 20:05:47

I have a table with some identifiers that repeat themselves like

我有一个表格,其中包含一些重复的标识符

id
-------
djkfgh
kdfjhw
efkujh
dfsggs
djkfgh
djkfgh
efkujh

I also have a list of id's of interest, say ["djkfgh","dfsggs"]. I would like to count only those values that appear in the list, rather than all the distinct values of the column.

我还有一个感兴趣的id列表,比如[“djkfgh”,“dfsggs”]。我想只计算列表中出现的那些值,而不是列的所有不同值。

1 个解决方案

#1


1  

Select count(id) from table where id IN(subset);

#1


1  

Select count(id) from table where id IN(subset);