P
P
pgamesorg2021-11-19 21:42:12
MySQL
pgamesorg, 2021-11-19 21:42:12

How to display the value that repeats the most?

let's say I have:

1б2, 34, 56, 7,  7,  7,  7,  7,  7,  7, 4, 7, 3, 4, 5, 7,  7,  7


how to get only 7 from such lines for example?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alexbprofit, 2021-11-19
@alexbprofit

if they are in the table:
select distinct(value) from table where value=7

G
galaxy, 2021-11-19
@galaxy

Well, for example:

select i from t group by i order by count(*) desc limit 1;

sqlfiddle.com/#!17/d1148/1

V
Vladimir Yasankin, 2021-11-20
@jsnk

In the acc array (the key is the value from the ref array), you add the current index of the ref array with a separator to the value.
In the array you find the longest list and form a string by indexes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question