AND 对象金额〈金额(金额最小的那条记录。) 如果对象金额=30,抽出的纪录为: 20040301 1 60 C 这个对象金额的条件没看懂,如果楼主是为了oracle上运行,建议转到oracle版
//开始日=(20041231日这一年最新的那个日子) AND 对象金额〈金额(金额最小的那条记录。)什么意思﹖ 為什么不是這條記錄﹖20040101 1 20 A
sql写法select * from tablename where 开始日=(select max(开始日) from tablename where 开始日<='20041231' and 开始日>='20040101') and SEQ=(select top 1 SEQ from tablename where 开始日=a.开始日 order by 金额)可惜在oracle下肯定不行
写错了select * from tablename a where 开始日=(select max(开始日) from tablename where 开始日<='20041231' and 开始日>='20040101') and SEQ=(select top 1 SEQ from tablename where 开始日=a.开始日 order by 金额)
对象金额?是不是这样? select * from tablename a where 开始日=(select max(开始日) from tablename where 开始日<='20041231' and 开始日>='20040101' and 金额>=30) and SEQ=(select top 1 SEQ from tablename where 开始日=a.开始日 and 金额>=30 order by 金额)
select * from test where qian=(select min(qian) from test where somedate=(select max(somedate) from test where somedate<'20050101'))
懒得打中文了,'qian'就是金额,'somedate'就是日期。
select top 1 a.* from 表 a where [开始日]<='20041231' and [金额]>=30 order by [开始日] desc ,[金额] asc
如果对象金额=30,抽出的纪录为:
20040301 1 60 C
这个对象金额的条件没看懂,如果楼主是为了oracle上运行,建议转到oracle版
AND 对象金额〈金额(金额最小的那条记录。)什么意思﹖
為什么不是這條記錄﹖20040101 1 20 A
where 开始日=(select max(开始日) from tablename where 开始日<='20041231' and 开始日>='20040101')
and SEQ=(select top 1 SEQ from tablename where 开始日=a.开始日 order by 金额)可惜在oracle下肯定不行
where 开始日=(select max(开始日) from tablename where 开始日<='20041231' and 开始日>='20040101')
and SEQ=(select top 1 SEQ from tablename where 开始日=a.开始日 order by 金额)
select * from tablename a
where 开始日=(select max(开始日) from tablename where 开始日<='20041231' and 开始日>='20040101' and 金额>=30)
and SEQ=(select top 1 SEQ from tablename where 开始日=a.开始日 and 金额>=30 order by 金额)
from 表 a
where [开始日]<='20041231'
and [金额]>=30
order by [开始日] desc ,[金额] asc