注册 登录
编程论坛 SQL Server论坛

求助 查询一定条件之下 关键字段不重复的查询语句

sandy186 发布于 2007-03-06 08:21, 716 次点击
各位高手请教一个查询语句:要将下面的表:

ffgcode fordqty fordup .....
a 40 98
b 50 90
c 80 50
a 100 94
b 30 92
a 30 150
.
.
.
查询出 fordqty小于等于50 并且fordup要在95到100之间 ffgcode 中重复的只显示一个
请问应该怎么写?请指点指点
2 回复
#2
棉花糖ONE2007-03-06 08:56
select distinct * from (select * from s where fordqty<=50 and fordup between 95 and 100) a where binary_checksum(*) in ( select top 1 binary_checksum(*) from (select * from s where fordqty<=50 and fordup between 95 and 100) b where a.ffgcode=b.ffgcode)

[此贴子已经被作者于2007-3-6 10:37:33编辑过]

#3
sandy1862007-03-06 11:06
呵呵!谢谢斑竹了.
1