CREATE TEMPORARY TABLE tmp_emp_ids1 AS
select array_agg(a.id order BY a.id) as "ids" from hr.hr_employee a
inner join hr.hr_employee_trans_record b on b.employee_id = a.id
where
b.del_flag = '0'
and b.type='1'
and '2019-08-08' <= b.start_date::date
--图1

select * from hr.hr_employee
where array[id]::bigint[] <@ (select ids from tmp_emp_ids1)
--图2

本文探讨了在SQL中创建临时表进行数据聚合的方法,并展示了如何使用数组操作来筛选特定条件下的员工记录。通过内连接和类型筛选,实现了对有效期内员工ID的高效查询。
1700

被折叠的 条评论
为什么被折叠?



