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 810723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:55:51+00:00 2026-05-15T00:55:51+00:00

hey guys, just having a bit of difficulty with a query, i’m trying to

  • 0

hey guys, just having a bit of difficulty with a query, i’m trying to figure out how to show the most popular naturopath that has been visited in a centre. My tables look as follows;

Patient(patientId, name, gender, DoB, address, state,postcode, homePhone, businessPhone, maritalStatus, occupation, duration,unit, race, registrationDate , GPNo, NaturopathNo)

and

Naturopath (NaturopathNo, name, contactNo, officeStartTime, officeEndTime, emailAddress)

now to query this i’ve come up with

SELECT count(*), naturopathno FROM dbf10.patient WHERE naturopathno != 'NULL' GROUP BY naturopathno;

which results in;

  COUNT(*) NATUROPATH
     2 NP5
     1 NP6
     3 NP2
     1 NP1
     2 NP3
     1 NP7
     2 NP8

My question is, how would I go about selecting the highest count from this list, and printing that value with the naturopaths name? Any suggestions are very welcome,

  • 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-15T00:55:51+00:00Added an answer on May 15, 2026 at 12:55 am

    You can use the RANK analytic function – this will assign rank “1” to the topmost naturopath, or naturopaths if there is a tie for first place:

    SELECT (select name from Naturopath n
            where n.NaturopathNo = q.naturopathno)
           as TopNaturopathName,
          ,q.patients
    FROM (
     SELECT naturopathno, patients,
            RANK() OVER (ORDER BY patients DESC) rnk
     FROM (
      SELECT COUNT(*) AS patients, naturopathno
      FROM dbf10.patient
      WHERE naturopathno is not null
      GROUP BY naturopathno
     )
    ) q
    WHERE rnk = 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, just trying to decode my signed request.. I've done a bit of
Hey guys, I'm having a bit of trouble with my ASP:RadioButtonList, searched Google and
Hey guys I am having a lot of trouble trying to understand this and
Hey guys I am having trouble trying to convert my web app to support
Hey guys, just another little problem here! Trying to write a quiz for a
Hey guys. Just like in the title - I'm having some problems doing it.
Hey guys, I'm just starting out with GWT and am getting the following error
Hey guys, I'm starting with Zend, and trying to understand the way it works
hey guys, how can I just achieve this simple layout? I'm hoping the answer
Hey guys, I'm brand new to Visual C++, but not C++. I'm having issues

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.