语句合并问题

zqycn518 2010-09-24 06:09:21
select max(日期) from 收入 where 编号=1003
得到的值加入到

select t2.名称.t2.金额,t2.日期 form 资料 t1,收入 t2 where t1.编号 = t3.编号 and t1.编号=1003

请问需要怎么做
...全文
67 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2010-09-24
  • 打赏
  • 举报
回复
try~~
select t2.名称.t2.金额,t2.日期 
form 资料 t1,收入 t2
where t1.编号 = t2.编号
and t1.编号=1003
and not exists(select null from 收入 m where m.日期 >t2.日期 and t2.编号 =编号 )

SQLCenter 2010-09-24
  • 打赏
  • 举报
回复
select t2.名称.t2.金额,t2.日期,(select max(日期) from 收入 where 编号=t1.编号) form 资料 t1,收入 t2 where t1.编号 = t3.编号 and t1.编号=1003
昵称被占用了 2010-09-24
  • 打赏
  • 举报
回复
是不是要如下效果

select t2.名称,t2.金额,t2.日期 form 资料 t1,收入 t2 where t1.编号 = t3.编号 and t1.编号=1003  
union all
select '',null,max(日期) from 收入 where 编号=1003

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧