Case: While querying each item id, make statistics on all items under the company to which the item belongs
一、group by
Description: group by company : group company, it should be noted that all the columns to be queried except for the aggregate function must be carried after group by
SELECT id,company,count(company) from ITEM_MAIN_LIST group by company,id
Renderings
Summary: According to the query results, while finding out the id of each item, it is impossible to count the same company
二、COUNT (*) OVER (PARTITION BY)
Description: COUNT (id) OVER (PARTITION BY company) : count / statistic of id according to company
SELECT id,company,COUNT (ID) OVER (PARTITION BY company) AS num FROM ITEM_MAIN_LIST
Renderings
Summary: While finding the id, you can count the same company