SQL - Campaign and there Certifications in last 30 days

 SELECT ce.certkey      AS 'Certification ID',

       c.campaign_name AS 'campaign name',
       CASE c.status
         WHEN 1 THEN 'In Progress'
         WHEN 2 THEN 'Completed'
         WHEN 5 THEN 'In Progress'
         WHEN 4 THEN 'Preview'
         WHEN 6 THEN 'Discontinued'
         WHEN 7 THEN 'Expired'
         WHEN 8 THEN 'Launching'
       END             AS 'Campaign Status',
       ce.cert_name    AS 'Certification Name',
       CASE
         WHEN ce.status = 0 THEN 'New'
         WHEN ce.status = 1 THEN 'In Progress'
         WHEN ce.status = 2 THEN 'Completed'
         WHEN ce.status = 3 THEN 'Locked'
         WHEN ce.status = 4 THEN 'Expired'
         WHEN ce.status = 7 THEN 'Discontinued'
         WHEN ce.status = 8 THEN 'Locked and Task Created'
         ELSE NULL
       END             AS 'Certification Status',
       u.displayname   AS 'Certifier Name',
       c.start_date    AS 'Campaign Start Date',
       c.end_date      AS 'Campaign End Date'
FROM   campaign c,
       certification ce,
       users u
WHERE  c.start_date >= Date_sub(Curdate(), interval 30 day)
       AND c.id = ce.campaignkey
       AND ce.certifier = u.userkey 

rushikeshvartak_0-1714538677561.png

 

Comments

Popular posts from this blog

Enhanced Query - To Update Account Status and Name

Connection Config - STATUS_THRESHOLD_CONFIG

Email variables _ Register User