Answers for "tsql find the value and count of the item that occurs the most in a column"

SQL
0

tsql find the value and count of the item that occurs the most in a column

select item, cnt
from (
  select
  	item
  	,cnt = count(*)
  	,seqnum = row_number() over (partition by id order by count(*) DESC)
  from 
  	src_table
  group by
  	item
) sub_qry

where seqnum = 1;
Posted by: Guest on February-20-2021

Code answers related to "tsql find the value and count of the item that occurs the most in a column"

Code answers related to "SQL"

Browse Popular Code Answers by Language