1

I have a rather large employee feed coming in and each employee has about 50 fields.

I take the employee data and add on a bunch of other stuff and this gets outputted to one of our vendors. Most of the outputted data is via Views where I take LDAP data and then other tables/views that my team does mapping.

So one of our vendors asked us can we just get the employees whose job_role has changed? Well the job_role field is done through mapping on our Job_role_map View which uses the LDAP job_title field.

Is there a way that I can report in my final view when the job_role has changed? So this could change via the main LDAP field or we could change the mapping for their job_title.

Main LDAP create

DROP TABLE
IF EXISTS testgiver.ldap_karen;

CREATE TABLE testgiver.ldap_karen (uid VARCHAR (10) NOT NULL PRIMARY KEY) 
SELECT
  ldap_full.uid as 'uid',
    ldap_full.xyznamedisplay,
    ldap_full.businesscategory,
    ldap_full.mail,
    ldap_full.givenname,
    ldap_full.sn,
  ldap_full.xyzjobcode,
    ldap_full.departmentnumber,
    ldap_full.title,
    ldap_full.xyzmgdescr,
    ldap_full.xyzmgdescroverride,
    ldap_full.xyzcompanydescr,
    ldap_full.xyzcompanydescroverride,
    ldap_full.xyzlocationstreet1,
    ldap_full.xyzlocationcity,
    ldap_full.xyzlocationstatedescr,
    ldap_full.xyzlocationpostal,
    ldap_full.xyzlocationcountry,
    ldap_full.xyzlocationcountrydescr,
    ldap_full.xyzsupervisorid,
    ldap_full.xyzsupervisoriddescr,
    ldap_full.xyzcompanyshortdescroverride,
            CASE
        WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Go To Market Europe-ALL' THEN 'F&R Go To Market Europe-ALL'
        WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Go To Market Americas-ALL' THEN 'F&R Go To Market Americas-ALL'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Go To Market Asia-ALL' THEN 'F&R Go To Market Asia-ALL'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Go To Market Strategic Customers & Solutions-ALL' THEN 'F&R Go To Market Strategic Customers & Solutions-ALL'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Go To Market Strategy & Operations-ALL' THEN 'F&R Go To Market Strategy & Operations-ALL'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Financial-ALL' THEN 'F&R Financial'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Finance - ALL' THEN 'F&R Financial'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Investors - ALL' THEN 'F&R Financial'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Trading - ALL (inactive)' THEN 'F&R Financial'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Marketplaces - ALL (inactive)' THEN 'F&R Financial'
                WHEN ldap_full.xyzbulevel1descr LIKE '%Risk%' THEN 'F&R Risk'
                WHEN ldap_full.xyzbulevel1descr LIKE '%GRC%' THEN 'F&R Risk'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Unified Platform Group-ALL' THEN 'F&R Unified Platform Group-ALL'
                WHEN ldap_full.xyzbulevel1descr LIKE 'F&R Content, Analytics & Valuation Srvs-ALL' THEN 'F&R Content, Analytics & Valuation Srvs-ALL'
        WHEN ldap_full.xyzbulevel1descr LIKE '%GGO%' THEN 'GGO'
                WHEN ldap_full.xyzbulevel1descr LIKE '%News%' THEN 'abc'
                WHEN ldap_full.xyzbulevel1descr LIKE '%abc%' THEN 'abc'
                ELSE 'Other'
      END as sa_bu,
    ldap_full.xyzbulevel1descr,
    ldap_full.xyzbulevel1shortdescr,
    ldap_full.xyzbulevel2descr,
    ldap_full.xyzbulevel2shortdescr,
    ldap_full.xyzroleindicatordescr,
    ldap_full.xyzjobcodedescr,
    ldap_full.xyzjobfamilycode,
    ldap_full.xyzjobfamilydescr,
    ldap_full.xyzrecordtypedescr,
    sup_email.mail AS supemail, 
  reports_regionnames.regionname,
  ldap_karen_helper1.sa_title

FROM
    ldap_full
LEFT JOIN ldap_karen_helper1 ON ldap_full.uid = ldap_karen_helper1.uid
LEFT JOIN ldap_full AS sup_email ON ldap_full.xyzsupervisorid = sup_email.uid
LEFT JOIN reports_regions ON ldap_full.xyzlocationcountrydescr = reports_regions.xyzlocationcountrydescr
LEFT JOIN reports_regionnames ON reports_regions.xyzregion1 = reports_regionnames.regiondid

Helper table for the table above

SELECT
ldap_full.xyzjobcodedescr,
reports_salesroles.jobroleid,
reports_jobroles.groupabrev AS sa_title,
ldap_full.mail,
ldap_full.uid,
ldap_full.xyzroleindicatordescr,
ldap_full.xyzsupervisorid
FROM
reports_salesroles
INNER JOIN reports_jobroles ON reports_salesroles.jobroleid = reports_jobroles.nameid
INNER JOIN ldap_full ON ldap_full.xyzjobcodedescr = reports_salesroles.xyzjobcodedescr 

Job Role Mapping table - our admin team maps corporate job titles to job_roles.

DROP TABLE IF EXISTS `reports_jobroles`;
CREATE TABLE `reports_jobroles` (
  `nameid` int(11) NOT NULL AUTO_INCREMENT,
  `groupname` varchar(50) NOT NULL,
  `groupabrev` varchar(5) NOT NULL,
  `notes` longtext,
  PRIMARY KEY (`nameid`),
  KEY `rolename` (`nameid`,`groupname`,`groupabrev`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;

If you need more tables/examples let me know. These are all pushed to views that just give employee data/role data that is spit out to vendors so that vendors can put people in buckets for whatever.

4
  • 1
    Could you add details describing the tables and views involved, etc? Without something to go on, this is difficult to answer reliably. Thanks!
    – Hannah Vernon
    Commented Jul 31, 2015 at 16:39
  • @MaxVernon - Adding now.
    – LOSTinDB
    Commented Jul 31, 2015 at 17:02
  • +5 hours; still no SHOW CREATEs
    – Rick James
    Commented Jul 31, 2015 at 22:33
  • 1
    @RickJames - sorry was at work. And you wouldn't believe that I don't have access to our main internet server at work! (my home IP is whitelisted but we can't get a secure connect through corporate firewalls)
    – LOSTinDB
    Commented Aug 1, 2015 at 2:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.