一个SQL问题 本帖最后由 ssniu1985 于 2010-02-08 11:38:36 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 表 READ 字段 : ID DATE MOUNT 01 1/2/2010 1 01 2/2/2010 2 01 3/2/2010 3 02 1/2/2010 7 02 2/2/2010 8 03 1/2/2010 9 03 2/2/2010 8 要得到的结果:抽出这三条 01 3/2/2010 3 02 2/2/2010 8 03 2/2/2010 8 3+8+8=19 select sum(tmount)from temp awhere not exists( select 1 from temp where tid=a.tid and tdate>a.tdate)试试 select sum(MOUNT) s_mount from read where (id,date) in (select id,max(date) date1 from read group by id) 不知道这个在access里是否可以用。 select sum(mount) from (select top 1 ID , DATE ,MOUNT from READ order by DATE desc group by ID)试试,不太会用标准SQL了 这个语句可以:select sum(t2.mount) from (select id,max(dat) as dat from test2 group by id) t1,test2 t2 where t1.id=t2.id and t1.dat=t2.dat 那么你的tdate应该是字符型的吧,因为格式是DD/MM/YY,需要转成date再比较 请问tnsnames.ora的配置问题 用exp导出数据库错误揭示 求一sql查询语句 急!用recover database until time恢复数据库出错 数据库无法修改与非键值保存表对应的列 请教各位大师,Oracle9i 如何只显示当天的记录? 有关oracle9i的TNSListener的三个端口的讨论 在线等待高手解答 oracle insert的字符串中如何包含 & 的问题 ORACLE问题 sql分组难题 一个PL/SQL问题
字段 : ID DATE MOUNT
01 1/2/2010 1
01 2/2/2010 2
01 3/2/2010 3
02 1/2/2010 7
02 2/2/2010 8
03 1/2/2010 9
03 2/2/2010 8
要得到的结果:抽出这三条 01 3/2/2010 3 02 2/2/2010 8 03 2/2/2010 8
3+8+8=19
from temp a
where not exists(
select 1 from temp
where tid=a.tid and tdate>a.tdate)
试试
select top 1 ID , DATE ,MOUNT
from READ
order by DATE desc group by ID)
试试,不太会用标准SQL了
select sum(t2.mount) from (select id,max(dat) as dat from test2 group by id) t1,test2 t2 where t1.id=t2.id and t1.dat=t2.dat