疑难SQL语句 请教高手 这个是表内容我想做一个查询SELECT ID,编号,日期, 数量,MAX(日期2), (-这里加上MAX(日期2) 对应的ID2-) from T GROUP by ID,编号,日期, 数量这个有办法实现吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select ID,编号,日期, 数量,[最大日期],ID2 from T where 日期2 in( SELECT [最大日期]from( SELECT ID,编号,日期, 数量,[最大日期]=MAX(日期2) from T GROUP by ID,编号,日期, 数量 )a) SELECT ID,编号,日期, 数量,日期2,ID2 from T awhere not exists (select 1 from T where ID=a.ID and 日期2>a.日期2) SELECT ID,编号,日期, 数量,日期2,ID2 from T a where not exists ( select 1 from T where ID=a.ID and 编号 = a.编号 and 日期 = a.日期 and 数量 = a.数量 and 日期2>a.日期2 ) SQL中怎样将得到的数值型结果转换为两位小数? 求SQL语句.把三个语句合在一起运行 请SQL SERVER2000个人版 [DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问??????? 讨论!何时应该采用存储过程,何时不宜采用存储过程? 求select由or连接的优化SQL语句 安装完msde后当如合作 关于中文字符多条件判断模糊查询问题,求教大大门 SQL语句的求助 一个关于范式的问题(3NF or 2NF) 触发器语句请教 大数据量更新,如何提高速度
SELECT [最大日期]from(
SELECT ID,编号,日期, 数量,[最大日期]=MAX(日期2) from T
GROUP by ID,编号,日期, 数量
)a
)
where not exists (select 1 from T where ID=a.ID and 日期2>a.日期2)
from T a
where not exists (
select 1
from T
where ID=a.ID
and 编号 = a.编号
and 日期 = a.日期
and 数量 = a.数量
and 日期2>a.日期2
)