请把我的SQL 代码放到查询分析器里。 然后按我说的运行,告诉我 我问的问题,谢谢高手了 if not object_id('ta') is null drop table ta Go Create table ta([product] nvarchar(2),[spec] nvarchar(2)) Insert ta select N'p1',N's1' union all select N'p1',N's2' union all select N'p1',N's3' union all select N'p2',N's5' union all select N'p2',N's4' Go select * from ta t where [spec] = (select top 1 [spec] from ta where [product]=t.[product] order by newid())
问题1 我把 [spec] = 里的等号换成 in 多次按F5运行后 就会出现条数 0到5条之间为什么。我认为 这时候=号应该和in是一个结果,我top1了, in和 newid 有什么冲突吗? 问题2 我把 = 该成 in 后 我把newid() 该成固定列比如spec F5后 条数就一样了。为什么。 如果回答的清楚,我追加分。 。谢谢因为spec有重复值。 [spec]的值有重复 spec有重复值 1 2 楼的, 你运行我的数据了吗? spec 是从s1 到s5 你说的重复值我没懂 UP = 跟 in 之间是有差别的.