gpt4 book ai didi

mysql - 当 count > x 时显示单独的行

转载 作者:行者123 更新时间:2023-11-29 11:46:56 24 4
gpt4 key购买 nike

我有一个数据库,其中包含 record_number(PRIMARY)、owner_name、地址。

我想识别拥有多个属性(property)的owner_name,并列出owner_name 拥有的每项属性(property)。

类似于:

record_number   | owner_name      |  address
1 | Smith | 123 Main
7 | Smith | 1 Some Street
12 | Smith | 77 Dude Ln
19 | Jones | Some address
21 | Jones | Some Different address
47 | Jones | Yet another address
106 | Davis | You're getting the idea?
139 | Davis | All of these are different!
141 | Davis | They keep changing
158 | Davis | When will it end?

最佳答案

select record_number, owner_name, address
from your_table
where owner_name in
(
select owner_name
from your_table
group by owner_name
having count(*) > 1
)
order by owner_name, record_number

关于mysql - 当 count > x 时显示单独的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34763073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com