Неправильно выглядит GROUP BY:
select Split_Part("EmpName",'_',1) splited_name,
"EmployeeID",
sum("TotalDays"::decimal) as "temp"
from "Leave_Log"
where date("StartDate") between '2018-01-01' and '2018-12-31'
and "Staus"='Approved'
and "EmployeeID" in (Select "UserName"
from "Master_Employees"
where "Status"='Y')
group by splited_name,"EmployeeID"
order by splited_name
например: если у вас есть таблица
CREATE TABLE public.users
(
id integer NOT NULL DEFAULT nextval('users_user_id_seq'::regclass),
email character varying(100) NOT NULL,
salary integer,
CONSTRAINT users_pkey PRIMARY KEY (id),
CONSTRAINT users_email_key UNIQUE (email)
)
, тогда запросы
SELECT Split_Part(email, '@', 2) split_email, sum(salary)
FROM users
GROUP BY email
ORDER BY email
AND
SELECT Split_Part(email, '@', 2) split_email, sum(salary)
FROM users
GROUP BY split_email
ORDER BY split_email
даст вам другой ответ