首页 > 其他分享 >分组后A列最大的B列

分组后A列最大的B列

时间:2022-09-19 08:58:46浏览次数:68  
标签:salary old 最大 employee 分组 date id log

分组后A列最大的B列 ,分组:employee_id  A列:log_date   B列:old_salary  

select * from "plch_emp_log" order BY "employee_id","log_date";

select "employee_id",
replace(lpad('123',4),' ','0'),
min("log_date"),
MIN("old_salary") KEEP(DENSE_RANK FIRST ORDER BY "log_date"),
TO_NUMBER(SUBSTR(MIN(TO_CHAR("log_date",'YYYYMMDDHH24MISS')||"old_salary"),15)),-- 分组后,取log_date最小记录的old_salary
"SUM"("new_salary")
from "plch_emp_log" GROUP BY "employee_id";

标签:salary,old,最大,employee,分组,date,id,log
From: https://www.cnblogs.com/xlj227/p/16706520.html

相关文章