需求描述:一个表MyImage,列有:号码ID,路径PATH
如:ID PATH
1 C:/
1 C:/
1 D:/
2 C:/
2 C:/
3 A:/
3 C:/
4 D:/写个sql语句,返回这样的记录的ID号:相同ID存在不同PATH。如上例子,正确的结果应是:
ID13(ID2没有不同PATH,ID4只有一条记录不存在不同PATH)
这是我的sql语句:
代码如下:
select ID from [MyImage] as A
group by ID
having
(
select COUNT(distinct(Path)) from [MyImage] as B where B.ID = A.ID
)
> 1
group by ID
having
(
select COUNT(distinct(Path)) from [MyImage] as B where B.ID = A.ID
)
> 1