请教大虾们一个SELECT语句的问题!谢谢!特急,在线等待!!! select a.* from tablename as a,(select id,max([date]) as date from tablename) as bwhere a.[date]=b.[date] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不行啊! (select id,max([date]) as date from tablename)这一句是不是就出错了? select id form tabename where date in (select min(date) from tablename) select aa.* from test as aa,(SELECT id,max(date) as date FROM TEST group by id )as bb where aa.[date]=bb.[date] select aa.* from TEST as aa,(SELECT id,max(date) as date from TEST group by id )as bb where aa.[date]=bb.[date]把test换成你的表名。 不行阿,我换了啊!表里有60条记录,可是用这个方法查出了1770条记录来!我用的是DB2数据库,我想应该根SQL语句没有太大关系吧! --就你上面的数据,下面肯定可以出结果。(在Ms SQLServer里)。 Select ID,Max(Date),Name From Test Group by ID,Name SQL SERVER中肯定可以这样:select id,max(date),name from 表 group by id,name select t1.id, t1.date, t1.namefrom tbl t1where exists (select * from tbl t2 where t2.id = t1.id group by t2.id having t1.date = max(t2.date))试试! select t1.id, t1.date, t1.namefrom 表 awhere not exists (select 1 from 表 b where a.id = b.id and a.date<b.date ) 按ID分组,取每组DATE最大值select id,max(date) from tablegroup by id select * from yourtable AA where [date]=(select max([date] from yourtable BBwhere AA.id=BB.id) select * from yourtable AA where [date]=(select max([date]) from yourtable BBwhere AA.id=BB.id) select id,max(date1),name from test group by id,name 97866(weiLuang)的语句可以用了,谢谢大家的帮助!现在封贴了! 基础的动态sql问题,不惧上问! 关于BCP命令的使用 很有意思~一个SQL查询问题~~急~~本人在线等 简单的查询问题,在线等。。。 求一个SQL 存储过程,关于时间段查询 [*求助*]联机丛书上的语法! 关于sp_executesql返回值疑问,急 重新启动一下机器,SQL Server突然不能启动了,怎么回事啊?在线等待~~ jsp中插入有主关键字(自动编号)的数据库的sql语句如何写??? 附加数据库错误是5120 求简单sql 添加记录行 想设数据库所有表的日期为某一固定格式,怎么设置?
select aa.*
from TEST as aa,(SELECT id,max(date) as date from TEST group by id )as bb
where aa.[date]=bb.[date]把test换成你的表名。
我用的是DB2数据库,我想应该根SQL语句没有太大关系吧!
select id,max(date),name from 表 group by id,name
from tbl t1
where exists (select *
from tbl t2
where t2.id = t1.id
group by t2.id
having t1.date = max(t2.date))
试试!
from 表 a
where not exists (select 1
from 表 b
where a.id = b.id and a.date<b.date
)
select id,max(date)
from table
group by id
where AA.id=BB.id)
where AA.id=BB.id)