select name from myschema.table1 where
COL1 = 'A'and
COL2= 'B' and
LEVEL = (select max(LEVEL) from myschema.table1 where USERTYPE='C')
我知道正在查询表中的最大级别,而不是用户类型为“c”的行中的最大级别。我只需要查询具有该用户类型的用户。
最佳答案
你们很接近。您需要一个关联子句:
select t.name
from myschema.table1 t
where COL1 = 'A'and COL2= 'B' and
LEVEL = (select max(t2.LEVEL)
from myschema.table1 t2
where t2.col1 = t.col1 and g2.col2 = t.col2 and t2.USERTYPE = 'C'
);
关于mysql - 仅从某些行中选择列的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45594351/