0

1より大きいレコードの数とそのcity_idが異なる「grand_order_id」の数を見つける必要があります。

次のようなテーブル:

grand_order_id   city_id  
5085849206  1110101  
5085849206  1110103  
5085849326  1310101  
5085849386  1130304  
5085849386  1130303  
5085849386  1130304  
5085849566  1430101  
5085849566  1430101  

結果:
条件を満たす2つの grand_order_id は:

5085849386
5085849206

これを数えるにはSQLが必要です。

4

1 に答える 1

0
select grand_order_id   
from your_table
group by grand_order_id   
having count(distinct city_id) > 1
于 2013-10-24T10:29:11.777 に答える