Zhang San, Beijing
Zhang Yi, Beijing
Lee, Chengdu
Zhang Yi, Luo Yang
Lie triple, Shanghai
Lie triple, Shanghai
I want to get the result:
Zhang San, Beijing
Zhang Yi, Beijing
Beijing: 2 People
Lee, Chengdu
Chengdu: 1 People
Zhang Yi, Luo Yang
Drop Yang: 1 people
Lie triple, Shanghai
Lie triple, Shanghai
Shanghai: 2 people
Excuse me, can this SQL be implemented?
Please give some details,
Thank you
------to solve the idea----------------------
Select Name,add, (select COUNT (*) from AAAAA where Add=t.add) as CNT from AAAAA T ORDER by add
Will get
Zhang San, Beijing, 2
Zhang Yi, Beijing, 2
Lee, Chengdu, 1
Zhang Yi, Luo Yang, 1
Lie triple, Shanghai, 2
Lie triple, Shanghai, 2
You can judge it on the output.
------to solve the idea----------------------
Select DISTINCT (name), add, (SELECT COUNT (*) from AAAAA where Add=t.add) as CNT from AAAAA T ORDER by add
This is straightforward, no output to judge.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.