sql - use for COUNT command to create query in MYSQL -
below shows original sql table.
select name, count(city) "count_no" emp group name order count_no desc;
i need following result.
sam has 4 records. there city of london in 2 records. need how many different cities in sam's records. did lots of queries, couldn't create sql query.
add distinct count parameter:
select name, count(distinct city) "count_no" emp group name order count_no desc;
Comments
Post a Comment