select col1,max(col2) from table1 where col1 = (select max(col1) from table1)
select max(col1) as col1,max(col2) as col2 from table1
要出两列,没仔细看,改一下: SELECT col1, (SELECT MAX(col2) FROM table1 WHERE col1 = (SELECT MAX(col1) FROM table1)) FROM table1 语法烂了点,不过能出结果,还算健康,楼上的就要出错了。
少打了个字,对不起 SELECT MAX(col1), (SELECT MAX(col2) FROM table1 WHERE col1 = (SELECT MAX(col1) FROM table1)) FROM table1
select avg(col1) col1,max(col2) col2 from psm_employee where col1 in (select max(col1) from table1)
select avg(col1) col1,max(col2) col2 from table1 where col1 in (select max(col1) from table1)
create table table1(col1 int,col2 int) insert into table1 select 100,1 union select 100,4 union select 300,2 union select 300,3 select max(col1),(select max(col2) from table1 where col1= (select max(col1) from table1)) from table1
SELECT col1, (SELECT MAX(col2) FROM table1 WHERE col1 = (SELECT MAX(col1) FROM table1))
FROM table1
语法烂了点,不过能出结果,还算健康,楼上的就要出错了。
SELECT MAX(col1), (SELECT MAX(col2) FROM table1 WHERE col1 = (SELECT MAX(col1) FROM table1))
FROM table1
from table1
where col1 in (select max(col1) from table1)
insert into table1 select 100,1
union select 100,4
union select 300,2
union select 300,3
select max(col1),(select max(col2) from table1 where col1= (select max(col1) from table1)) from table1