Skip to content
Advertisement

Find the most frequent value ignoring everything after ‘(‘ within it

I am trying to find the most frequent string ignoring everything after ( within it.

So, how it should work. If I’ve got the strings:

It should return

because it’s the most frequent country here and no matter that as a string England (88) is going to pretend.

Unfortunately, my query returns

SQLfiddle

I’ve been thinking to do it by 2 steps:

  1. truncate every country string
  2. do script that I already written.

But I failed on the first step.

Advertisement

Answer

SQL Fiddle is acting up, so can’t test, but I’d think you could use SUBSTR() and INSTR() to isolate the portion left of the first (:

Edit: Tested on https://sqliteonline.com/ and it returns Iceland as expected: Fiddle.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement