怎样写这个查询

win1357 2003-10-10 10:54:47
两个表,要求查询表1中小于表2中某个字段值最大值
比如:通过查询表2 select column1 from tab1 where column2='111'
再查询表1 select max(col1<column1) from tab1
请教各位。
...全文
42 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yujohny 2003-10-10
  • 打赏
  • 举报
回复


select max(col1) from tab2
where col1< (select column1 from tab1 where column2='111')
txlicenhe 2003-10-10
  • 打赏
  • 举报
回复
sorry:
Select max(col1) from tab1 where column1 < (Select column1 from tab1 where column2 = '111')
txlicenhe 2003-10-10
  • 打赏
  • 举报
回复
Select max(col1) where column1 < (Select column1 from tab1 where column2 = '111') from tab1
伍子V5 2003-10-10
  • 打赏
  • 举报
回复
select max(a.col1) from table1 a
inner join table2 b
on a.col1<b.column1 and b.column2='111'
welyngj 2003-10-10
  • 打赏
  • 举报
回复
select top 1 col1 from tabl1 where col1<(select column1 from tab2 where column2='111') order by col1 desc
aierong 2003-10-10
  • 打赏
  • 举报
回复

create table ai(i int,ii int)
insert into ai select 1,2
insert into ai select 2,2
insert into ai select 3,2

create table aii(i int,ii int)
insert into aii select 1,2
insert into aii select 2,2
insert into aii select 3,2

select max(a.i)
from ai as a join aii as b
on a.i<b.ii

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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