问个问题
select employee_id,max(rem4) from Evaluate where rem1=1 group by employee_id
请问,我还想在select这边加一个字段如test_no,这个字段也是这个表里的,但是报错,请问还有什么方法吗?注:employee_id是用户名
rem4是时间
select employee_id,max(rem4) from Evaluate where rem1=1 group by employee_id
请问,我还想在select这边加一个字段如test_no,这个字段也是这个表里的,但是报错,请问还有什么方法吗?注:employee_id是用户名
rem4是时间
也要放到group by里
要么 聚合这个列test_no
或
select employee_id,max(test_no) as test_no,max(rem4) from Evaluate where rem1=1 group by employee_id
max(test_no) as test_no--在select 處
select * from Evaluate t where rem4=(select max(rem4) from Evaluate where employee_id=t.employee_id)
employee_id,test_no,rem4
from
Evaluate t
where
rem4=(select max(rem4) from Evaluate where employee_id=t.employee_id)
and
rem1=1
max(里面是时间,接近现在,就出来) test_no 是测试号
from evaluate a
where rem1=1
and not exists(select 1 from evaluate where rem1=1 and employee_id=a.employee_id and rem4>a.rem4)
max(rem4) from Evaluate where rem1=1 group by employee_id改為
select * from Evaluate as a where rem1=1 not exists(select 1 from Evaluate where rem1=a.rem1 and rem4>a.rem4)
select * from Evaluate as a where rem1=1 not exists(select 1 from Evaluate where rem1=a.rem1 and employee_id=a.employee_id and rem4>a.rem4)