Click HERE to see how Saviynt Intelligence is transforming the industry. |
03/21/2024 01:42 PM
I have requirement to send the terminated users details with All terms year-to-date, term date, and sort by most recent date at the top.
I tried with below sql order by termdate options but when I verified the result in email attachment. It's not sort by most recent date .
SELECT FIRSTNAME, LASTNAME, EMAIL, CASE STATUSKEY WHEN '0' THEN 'INACTIVE' WHEN '1' THEN 'ACTIVE' END AS USERSTATUS, DEPARTMENTname as 'DEPARTMENT' ,TiTle as 'Title', Termdate as 'Terminated Date' FROM USERS WHERE Termdate between '2024-01-01' and DATE_SUB(CURDATE(), INTERVAL 0 DAY) AND STATUSKEY = 0 order by termdate desc;
or
SELECT FIRSTNAME, LASTNAME, EMAIL, CASE STATUSKEY WHEN '0' THEN 'INACTIVE' WHEN '1' THEN 'ACTIVE' END AS USERSTATUS,DEPARTMENTname as 'DEPARTMENT' , termdate ,DATE_FORMAT(Termdate, '%Y-%m-%d')
as 'Terminated Date' , TiTle as 'Title' FROM USERS WHERE Termdate between '2024-01-01' and DATE_SUB(CURDATE(), INTERVAL 0 DAY) AND STATUSKEY = 0 order by DATE_FORMAT(Termdate, '%Y-%m-%d');
03/25/2024 08:30 PM - edited 03/25/2024 09:06 PM
03/28/2024 07:44 PM
Analytics always sort based on first column in report. try below
SELECT DATE_FORMAT(Termdate, '%Y-%m-%d')
as 'Terminated Date',FIRSTNAME, LASTNAME, EMAIL, CASE STATUSKEY WHEN '0' THEN 'INACTIVE' WHEN '1' THEN 'ACTIVE' END AS USERSTATUS,DEPARTMENTname as 'DEPARTMENT' , termdate , TiTle as 'Title' FROM USERS WHERE Termdate between '2024-01-01' and DATE_SUB(CURDATE(), INTERVAL 0 DAY) AND STATUSKEY = 0 order by DATE_FORMAT(Termdate, '%Y-%m-%d');