Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #tsql #find #count #item #occurs #column
ADD COMMENT
Topic
Name
6+3 =