Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:54:14+00:00 2026-06-11T18:54:14+00:00

I have a table named ‘data’ which stores the email addresses and city of

  • 0

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:

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

I have computed the answer using this query

  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)

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 answer

    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)

The query that i’m using is giving this error “FUNCTION e2.substring_index does not exist”. help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:54:15+00:00Added an answer on June 11, 2026 at 6:54 pm

    Your syntax is wrong for using the function. The alias goes on the column, not the function. For instance, your last subquery should use this syntax:

      from (select substring_index(e2.email,'@',-1) as strind,
                   count(substring_index(e2.email,'@',-1)) as No_of_Users
            from data e2
            group by substring_index (e2.email,'@',-1)
           ) x2
    

    I also named the first column, so you can refer to it outside the subquery if you want.

    To count the number of occurrences in a string, use this trick:

    (length(e2.email) - length(replace(e2.email, '@', '')) as numAmpersands
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a table named students which have student details id,mark,name i want to
I have a table named as person (which contains the login id of users).
I have a table named location , and I want to get some data
I have this table named OrdersToCall Data types: All bigints, except for date which
I have a table named tbl_Subjects_Taken which lists all the subjects taken by the
I have a table named Template which I set my messages to send them
I have a table named users and each row (user) has an image. The
I have a table named b having a column j which is varchar(3) where
i have a table named item with four attribute name,code,class,value now i want to
I have table named Schedule which has fields named TeacherName and ClassTakenDate.The values in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.