资料查询

danieltang 2005-03-22 04:18:52
表a数据

col1 col2 col3
a a1 a2
a a11 a12
b b1 b2
b b11 b12
....

表b数据
col1 col2 col3 col4
a t1 t2 s1
a t3 t4 s2
b t5 t6 s3

...

求当a.col1=b.col1 and [a.col2,a.clo3]包含于[b.col2,b.clo3]时,a.a2-a.a1-b.s1的一句SQL
...全文
112 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
davytao1018 2005-03-23
  • 打赏
  • 举报
回复
select a.col3-a.col2-b.col4 from 表A a,表B b where a.coll=b.coll and
(select col2,col3 from 表A where in(select col2,col3 from 表B))
danieltang 2005-03-23
  • 打赏
  • 举报
回复
求a.a2-a.a1-b.s1的值
chiwei 2005-03-22
  • 打赏
  • 举报
回复
感觉有点乱!
看不明白!
chinaandys 2005-03-22
  • 打赏
  • 举报
回复
select * from 表a a join 表b
on a.col1=b.col1 and
exists ((select a.col2 union all a.col3) in (select b.col2 union all b.col3))


a.a2-a.a1-b.s1 ?

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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