<?php
$x = 1;
$tahun = 2022;
$data = array();
while($x <= 3) {
array_push($data,($tahun));
$tahun = $tahun-1;
$x++;
}
$hasil = implode(',',$data);
var_dump($hasil);
$sql = "SELECT count(*) nilai FROM {$ref_table} WHERE emp_id = '{$emp_id}' AND flag_del = 'N'
AND YEAR(begin_date) IN ($hasil)";
?>