数据库中共有737条记录,但是name字段有重复记录,用
select distinct name from 表名
语句共查出659条记录,我想让查出来的记录按日期排序,比如说字段名是date,
select distinct name,date from 表名
共查出733条记录,但是有重复记录,请问,这条SQL语句应该怎么写才能使查出来的记录不重复?
select distinct name from 表名
语句共查出659条记录,我想让查出来的记录按日期排序,比如说字段名是date,
select distinct name,date from 表名
共查出733条记录,但是有重复记录,请问,这条SQL语句应该怎么写才能使查出来的记录不重复?
比方说你要最近的DATE那:
select distinct name,max(date) from 表名 group by name
order by date
select distinct name from tablename order by date这个是错误的,因为选择的字段中不包含date,所以不能按date排序
由于你在一组NAME中有多条记录,其DATA值又不一至,就样就只能在一组中取一个值出来,可以是最大\最小值等可以让系统唯一选定的.