Top 10 substances

select
  a.substance_id,
  b.name,
  count(distinct a.local_number)
from import.substance a 
  join import.substances b 
  on a.substance_id = b.substance_id 
GROUP BY 
  a.substance_id,
  b.name
order by 
  count(distinct a.local_number) desc
limit 10;
substance_idnamecount
42325700COVID-19 MRNA VACCINE PFIZER-BIONTECH (TOZINAMERAN)1034456
40995439COVID-19 VACCINE ASTRAZENECA (CHADOX1 NCOV-19)445801
40983312COVID-19 MRNA VACCINE MODERNA (ELASOMERAN)375783
50950LENALIDOMIDE165351
15756INFLIXIMAB124291
15535ETANERCEPT121607
20353METHOTREXATE110786
23893ACETYLSALICYLIC ACID108986
128670CALCIUM CHLORIDE, SODIUM CHLORIDE, GLUCOSE, SODIUM LACTATE, MAGNESIUM CHLORIDE106046
19980LEVONORGESTREL102116

(10 rows)