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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:14:21+00:00 2026-06-05T07:14:21+00:00

I have this question in some book I am reading right now..I am a

  • 0

I have this question in some book I am reading right now..I am a beginner to SQl..learning it..it is not my homework. I am just trying stuff on my own..

Sally wants to query the EMP table and determine how many of the employees live in each of the cities the company has factories in. She writes the following query but it does not work. What is wrong with the way the query is constructed?

SELECT city, COUNT(emp_no) as "Number of Customers"
FROM emp
ORDER BY city
GROUP BY city; 

This is what I did by referring to some other query which had count and group By used in it…I think we also need WHERE clause too in this query..how can i do it??

SELECT empid,count(*) “Employee Total”, city
From emp
Group by city;

Please help..thanks 🙂

  • 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-05T07:14:22+00:00Added an answer on June 5, 2026 at 7:14 am

    The problem with your first query is that order by should come after group by clause,

    SELECT city, COUNT(emp_no) as "Number of Customers"    FROM emp GROUP BY city Order By city;  
    

    The problem with your second query is that you are selecting empid however it’s not in Group by list.

    Try

    SELECT count(*) Employee Total, city From emp Group by city; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some question about arrays, I'm reading some book about Java, and now
I have this question, just in theory. I do some query results and there
I am trying to experiment this parameter in MapReduce and I have some question.
I came across this class while reading a C# book and have some questions.
I have seen this question and its answers and they clear up some of
Some people have mentioned RockScroll and MetaScroll in This Question , but those only
I have some questions, maybe stupid question. I have this url: http://flibusta.net/opds/opensearch?searchTerm=Тол&searchType=books and I
This question is hard to phrase, so I'm going to have to use some
I have read some different responses for this same question, so I dont know
I have question. I have some app on facebook and getting this error Fatal

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.