Saturday, 23 April 2016

SQL Query : Grouping and condition for result on aggregate function

Problem : List number of customers per city.
                 List the cities where the number of customers within the city is 2 or more.

  

Output the CITY and CUSTOMER_COUNT
 

SQL 
SELECT c.city, c.count(*)
FROM customer c
GROUP BY c.city
HAVING c.count(*) > 1

No comments:

Post a Comment

Note: only a member of this blog may post a comment.