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

  • SEARCH
  • Home
  • 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 7515433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:48:21+00:00 2026-05-30T00:48:21+00:00

I have a table with the following values (Please ignore index, here column with

  • 0

I have a table with the following values (Please ignore index, here column with R1..R10 being the PK of the table.

1   R1  M1  Mo1
2   R2  M2  Mo3
3   R3  M4  Mo6
4   R4  M2  Mo1
5   R5  M7  Mo1
6   R6  M5  Mo2
7   R7  M6  Mo1
8   R8  M4  Mo4
9   R9  M9  Mo3
10  R10 M3  Mo9

I want to find a value of Mo[i] for which number of R[i] are max. For example in above case Mo1 has maximum number of R[i] values so it must return Mo1.

I have been doing the stuff using count, but not succeeded yet.

Here is what i wrote

select Mo from table1 where Mo=(select max(r.Mo),max(count((r.Mo))) from table1 )r group by r.Mo
  • 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-05-30T00:48:22+00:00Added an answer on May 30, 2026 at 12:48 am

    Try this:

    select Mo from
    (
        select Mo from 
        (
            select Mo, count(*) cnt
            from table1
            group by Mo
        )
        order by cnt desc
    ) where rownum = 1;
    

    This first groups the table by the column Mo, resulting in

    Mo  | cnt
    ----+----
    Mo3 | 2
    Mo2 | 1
    Mo4 | 1
    Mo1 | 4
    Mo6 | 1
    Mo9 | 1
    

    It then orders this by the count which results in this:

    Mo 
    ---
    Mo1
    Mo3
    Mo6
    Mo2
    Mo4
    Mo9
    

    And then it simply returns the first row of the result which results in Mo1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table structure as follows: (please ignore the blackbox. was formatting
I have the following code: $sql = INSERT INTO table VALUES ('', ...); $result
I have the following query in VBA: DoCmd.RunSQL INSERT INTO table (value) VALUES ('example')
I have the following Python code: cursor.execute("INSERT INTO table VALUES var1, var2, var3,") where
Please Consider the following table : As you can see the Name column has
I have a table named OT Hours which has the following column EmpId, Date,
Assume I have the following style table, col1 col2 and col3 have same value
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
Let's say I have a table containing following data: | id | t0 |

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.