Note that there are some explanatory texts on larger screens.

plurals
  1. POsubstring_index function does not exist error
    primarykey
    data
    text
    <p>I have a table named 'data' which stores the email addresses and city of users and I want to find the most popular email domain. I use the following query to to find the rows which have maximum value. exapmple for my table:</p> <pre><code>Email Name City dsmks@gmail.com John California sak@gmail.com Leo sydney dsnk@gmail.com Ross NY askd@yahoo.com Ronny Canberra ajs@yahoo.com Monty London kasl@yahoo.com Jim washington uy@hotmail.com Finn Las vegas </code></pre> <p>I have computed the answer using this query</p> <pre><code> select x.city, x.No_of_People from (select e.city, count(e.city) as No_of_People from data e group by e.city) x where x.No_of_People = (select max(x2.No_of_People) from (select e2.city, count(e2.city) as No_of_People from data e2 group by e2.city) x2) </code></pre> <p>But i don't wan't to use limits as it does not return multiple rows. So I have used the following query using this <a href="https://stackoverflow.com/questions/12543723/selecting-multiple-maximum-rows">answer</a></p> <pre><code> select x.substring_index (email,'@',-1), x.No_of_Users from (select e.substring_index (email,'@',-1), count(e.substring_index (email,'@',-1)) as No_of_Users from data e group by e.substring_index (email,'@',-1)) x where x.No_of_Users = (select max(x2.No_of_Users) from (select e2.substring_index (email,'@',-1), count(e2.substring_index (email,'@',-1)) as No_of_Users from data e2 group by e2.substring_index (email,'@',-1)) x2) </code></pre> <p>The query that i'm using is giving this error "FUNCTION e2.substring_index does not exist". help me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload