使用了连接,大连接出了大量的重复行,怎么办? select *,日期=(select min(日期) from 表2 where id=表1.id) from 表1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select a.*,b.日期 from 表1 ainner join 表2 b on a.id=b.idwhere b.日期 = (select top 1 日期 from 表2 where id = b.id) select a.*,(select top 1 日期 from 表2 where id = a.id order by 日期) from 表1 a select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id and not exists(select * from 表2 b where b.id=表2.id and b.日期>表2.日期) select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id where 表2.id in(select top 1 日期 from 表2 order by 日期 asc) 不好意思,应该是select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id where 表2.日期 in(select top 1 日期 from 表2 order by 日期 asc) select a.*,b.日期 from 表1 ainner join 表2 b on a.id=b.idwhere b.日期 = (select top 1 日期 from 表2 where id = b.id) 就这个可以了. select a.*,b.日期 from 表1 a inner join 表2 b on a.id=b.id and not exists(select * from 表2 c where c.id=b.id and c.日期<b.日期) 数据库连接里的SLEEPING是不是还在连接? 急,sql2000安装问题 求视图自定义列执行顺序????? 触发器,当insert记录成功后,一个字段更新成insert成功记录的id,在线 各位大虾,将记事本的数据拷入数据库后,不能进行数据处理?比如求最大值 (这次希望图片能外联了)我的SQL 2008进不去,错误如图 字段查询问题 一个关于CONVERT的问题! vfp的grid控件动态改变记录源 高分求救:如何用JAVA来实现SQL Server的备份和恢复 请问这样怎么写呢? 一个分类的用sql写. 谢谢 关于事务处理机制的两个基础问题
inner join 表2 b on a.id=b.id
where b.日期 = (select top 1 日期 from 表2 where id = b.id)
不好意思,应该是
select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id where 表2.日期 in(select top 1 日期 from 表2 order by 日期 asc)
inner join 表2 b on a.id=b.id
where b.日期 = (select top 1 日期 from 表2 where id = b.id)
就这个可以了.