按特定字段筛选重复字段的记录,求助? select distinct number from tbwhere =2 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select distinct *from tablenamewhere =2 select * from t where =2union select * from t where =2 select min(number), from table where =2 group by number select distinct number, from tb where =2 --这个也可以 select distinct number,from tbwhere =2select number,from tbwhere =2group by number, select number, from 表 where =2 group by number, 现在要筛选出=2和只等于1的不重复记录,谢谢number 123 2125 2124 1 select distinct number from tbwhere =2 or =1 现在要筛选出=2和只等于1的不重复记录,谢谢number 123 2125 2124 1----------------------------楼主给的结果似乎和所给的描述对不上号哦,还是我的理解有误?楼主能否解析一下? select Number,count(*) from tablename group by Numberhaving count(*) =2 select Number,count(*) from tablename where =2group by Numberhaving count(*) >1 再把问题明确一下: (一个糟糕的表)number addtime 1234 1 12:00 1234 1 12:051234 2 12:151234 2 13:001235 1 13:451235 2 14:001236 1 14:161236 1 15:001236 1 16:00现在要筛选出=2的不重复记录(相同number任选一条)和只等于1的记录(相同number任选一条)换句话说就是一个number只选择一条记录,条件是=2或者全为1 这张表得有一个ID才行,有ID的时候select a.* from 表 a,(select min(id) as id, from 表 group by ) b where a.id=b.id 登录名只能映射到一个数据库用户名? 我怎么写一个得到一整个月的记录的SQL语句 高手幫忙,求一交叉表的SQL語句 一个小问题? 求个sql语句 请问如何在查询的成绩里加"名次"列? 解决马上结贴!!!!如何用SQL语句把生成的查询结果导出为Excel文件? sql字符集AMERICAN_AMERICA.WE8MSWIN1252 有关备份数据库的问题:需要 FSO 组件支持!FSO 是啥东东? 数据库难题!!!! 大容量复制失败原因? 我在一个字段里面存放这样的内容"以bug为动力,驱动团队流程自动化(192.168.0.16)",有n多条这样的纪录,但每条记录中最前面的字符串是不同
from tablename
where =2
union
select * from t where =2
from tb
where =2select number,
from tb
where =2
group by number,
现在要筛选出=2和只等于1的不重复记录,谢谢
number
123 2
125 2
124 1
from tb
where =2 or =1
number
123 2
125 2
124 1
----------------------------
楼主给的结果似乎和所给的描述对不上号哦,
还是我的理解有误?
楼主能否解析一下?
from tablename
group by Number
having count(*) =2
from tablename
where =2
group by Number
having count(*) >1
(一个糟糕的表)
number addtime
1234 1 12:00
1234 1 12:05
1234 2 12:15
1234 2 13:00
1235 1 13:45
1235 2 14:00
1236 1 14:16
1236 1 15:00
1236 1 16:00现在要筛选出=2的不重复记录(相同number任选一条)和只等于1的记录(相同number任选一条)换句话说就是一个number只选择一条记录,条件是=2或者全为1
select a.* from 表 a,(select min(id) as id, from 表 group by ) b where a.id=b.id