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 🙂
The problem with your
firstquery is thatorder byshould come aftergroup byclause,The problem with your
secondquery is that you are selecting empid however it’s not inGroup bylist.Try