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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:53:54+00:00 2026-06-10T05:53:54+00:00

How to find data for the following query Original Source question 89 Table structure:

  • 0

How to find data for the following query

Original Source question 89

Table structure:
Product(Maker, Model, Type)

Edit
Use sqlfiddle for schema

Task:
Find out those makers who have the most number of models in the
Product table as well as those who have the least number of models.
Output: maker, number of models

Hints given in question are GROUP BY, HAVING and IN

I tried various ways to find this basically what I came up with is I need to use Max(COUNT(model))

Result should be

maker   qty 
A        7 --max
C        1 --min

One solution I came up with is

select maker, count(ps.model) as Count from product as ps
group by ps.maker
having count(ps.model) in
(
select max(cnt) from (select count(model) as cnt from product group by maker)t
union
select min(cnt) from (select count(model) as cnt from product group by maker)t
)

Is there any other way.

  • 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-10T05:53:56+00:00Added an answer on June 10, 2026 at 5:53 am

    If you are using SQL Server 2008, you can simplify it with this: http://www.sqlfiddle.com/#!3/25ba8/7

    with counts as
    (
      select maker, count(ps.model) as Count from product as ps
      group by ps.maker
    )
    select cx.*
    from counts cx
    join
    (
      select min(count) as lo, max(count) as hi
      from counts
    ) as hi_lo 
    on cx.count = hi_lo.lo or cx.count = hi_lo.hi;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following query to get information about columns of a SQL Table
With following query I can find the data I want to delete: SELECT ab.id,
I'm using XOM with the following sample data: Element root = cleanDoc.getRootElement(); //find all
I want to use string similarity functions to find corrupted data in my database.
I'm trying to use the following query syntax from a php file: $sql =
I'm beggining with MYSQL. I have the following query: SELECT answers.data. * , COUNT(
I have a table for some voting(yes,no type) data with voter id. the table
I have a table of time-series data of which I need to find all
I was using the following query to try to find the differences between the
I ran the following query on a collection in my mongodb database. db.coll.find({field_name:{$exists:true}}).count() and

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.