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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:03:57+00:00 2026-05-26T05:03:57+00:00

Here is what my tables look like: CREATE TABLE Author( authorID INT PRIMARY KEY,

  • 0

Here is what my tables look like:

CREATE TABLE Author(
authorID INT PRIMARY KEY,
name VARCHAR(30)
);

CREATE TABLE book(
ISBN INT PRIMARY KEY,
title VARCHAR(30),
authorID INT,
inventory INT,
paperBack BOOLEAN,
fiction BOOLEAN,
FOREIGN KEY (authorID) REFERENCES Author(authorID)
);

I need to find out which author has written the most books.
I am working with a mixture of the following. I guess I am having trouble piecing it all together…

  SELECT authorID, count(*) 
    from book 
group by authorID;

I am not sure how to get the single row that has the highest count and then only get the authorID of that row. Once I have that authorID, I know how to get the name.

  • 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-26T05:03:58+00:00Added an answer on May 26, 2026 at 5:03 am

    If all you want is the ID of the author, then use ORDER BY and LIMIT 1 as others have pointed out. However, if you’re going to want other fields from Author, or if you are interested in multiple authors (second highest count, lowest count, etc), then you should consider joining to a derived table, like this:

    SELECT Author.*, d1.book_count
    FROM Author
      JOIN (SELECT authorID, count(authorID) as book_count FROM book GROUP BY authorID) d1
      ON Author.authorID = d1.authorID
    ORDER BY 
      d1.book_count
    

    Would give a result set like this:

     +----------------------------------+
     | AuthorID  |  Name  |  book_count |
     +----------------------------------+
     | 1         | bob    | 20          |
     | 9001      | sam    | 18          |
    
     ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the scenario: I have 2 tables: CREATE TABLE dbo.API_User ( id int NOT
Two temp tables are created and then loaded...Here's the schema. Create table #SH ([date]
I currently have database setup like so: CREATE TABLE `article` ( `id` int(11) NOT
Please look at this image here is 3 tables , and out i want
here is my 3 tables: table 1 -- stores user information and it has
I've got 3 tables that are something like this (simplified here ofc): users user_id
So imagine that you have a table of Products (ID int, Name nvarchar(200)) ,
Here's the scenario: I have 2 tables with data, one is the 2009 version
Here is my problem - I have 2 tables: WORKER, with columns |ID|OTHER_STAF| ,
Well here's my problem I have three tables; regions, countries, states. Countries can be

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.