PostgreSQL queries the number of occurrences of the same content of an attribute

nameQuery the number of occurrences of the same content in a database table attribute , and sort them from large to small.

SELECT name, COUNT(*) AS count
FROM your_table
GROUP BY name
ORDER BY count DESC;

Example

select project_id, COUNT(*) AS count
from app_ads_positions
group by project_id
order by count DESC;

operation result:

Insert image description here

Guess you like

Origin blog.csdn.net/xiaohuihui1400/article/details/133089394