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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:36:34+00:00 2026-06-14T19:36:34+00:00

I am learning MySQL with a sample database. I have a table production where

  • 0

I am learning MySQL with a sample database.
I have a table “production” where with columns: cd_code, company and year.
I would like to find which company has produced the most cds.

This:

select company, count(cd_code) from production group by company;

Which gives me the companies and how many CDs each has released.
Now from that table with columns (as appeared) company, count(code_cd)
I want to print the company which has the most CDs.
So I want the max of the 2nd column of the 2nd table.

What I am trying is this:

select max(res.cd_code) from (select company, count(cd_code) from production group by company) as res;

And I am getting error 1054:

Unknown column ‘cd_code’ in ‘field list’

What can I do?

Thank you for your time!

  • 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-14T19:36:35+00:00Added an answer on June 14, 2026 at 7:36 pm

    You are selecting company, count(cd_code) in res and hence there is no cd_code in res.

    If you want to access the count of the cd_code from res, then try below:

              SELECT max(res.COUNT_CODE) 
              FROM
                 (SELECT company, count(cd_code) AS COUNT_CODE 
                  FROM production 
                  GROUP BY company) as res;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If anyone could recommend a good book for learning mySQL as well, that would
I am learning to use mysql for rails apps, and I finally have been
So I have been learning quite a bit about PHP and Mysql, and I
I have a SQL Server database with lots of data and an empty MySQL
I am learning some myqli and would like to make a simple check. Basically,
I'm currently learning mysql, so I am very new to this, tried to find
I have written a simple database driven app in C# which uses a 2
I have a fairly simple table (forgive errors / stupidity, I'm still learning. Written
I have a MySQL database that contains all the words in the standard English
I am learning mysql join queries. To pratice, I decided to make tables for

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.