impalacrazy
IS-IT--Management
hi all, here is what i am trying to do and im wondering if it will work. i have a data universe (MPDB) that has the following feilds:
MPID / lastname / fistname / Title / Site / Medical Director name / Regional Director name.
i have a report that has the following
MPID|lastname|firstname|title|site|medical Director name|Regional director name.
now the MPID is the key for all data in the universe. i am trying to write a query that will allow me to have the report do the following:
MPID|lastname|firstname|title|site|MPID of medical director|medical Director name|MPID of regional director|Regional director name.
The query i ahve thus far is:
SELECT
dbo.ProviderTitleHistory.ProviderMasterID,
dbo.ProviderTitleHistory.TitleCode,
dbo.ProviderMaster.LastName,
dbo.ProviderMaster.PreferredName,
dbo.ProviderTitleHistory.SiteLocationName,
SiteLocationLookupFlat.RegionalDirectorName,
dbo.ProviderMaster.ProviderMasterID
FROM
dbo.ProviderTitleHistory,
dbo.ProviderMaster,
SiteLocationLookupFlat,
dbo.StaffHistory,
dbo.ProviderSiteLocationStaffGroup
WHERE
( dbo.ProviderMaster.ProviderMasterID=dbo.StaffHistory.ProviderMasterID )
AND ( dbo.ProviderTitleHistory.ProviderMasterID=dbo.StaffHistory.ProviderMasterID and dbo.ProviderTitleHistory.StaffGroup=dbo.StaffHistory.StaffGroup )
AND ( dbo.ProviderSiteLocationStaffGroup.ProviderMasterID=dbo.StaffHistory.ProviderMasterID and dbo.ProviderSiteLocationStaffGroup.StaffGroup=dbo.StaffHistory.StaffGroup )
AND ( SiteLocationLookupFlat.SiteLocationID=dbo.ProviderSiteLocationStaffGroup.SiteLocationID )
AND (
dbo.ProviderTitleHistory.ActiveFlag = 'Y'
AND dbo.ProviderTitleHistory.TitleCode = 'MD '
)
ORDER BY
1
i tried a case statement and an if statement to have the 2nd and 3rd MPID's in the report only pull if the title code was RD (regional director) but kept getting an error. Can anyone sugest a fix.
If i have made you head explode please let me know.
Thanks
Ivan
MPID / lastname / fistname / Title / Site / Medical Director name / Regional Director name.
i have a report that has the following
MPID|lastname|firstname|title|site|medical Director name|Regional director name.
now the MPID is the key for all data in the universe. i am trying to write a query that will allow me to have the report do the following:
MPID|lastname|firstname|title|site|MPID of medical director|medical Director name|MPID of regional director|Regional director name.
The query i ahve thus far is:
SELECT
dbo.ProviderTitleHistory.ProviderMasterID,
dbo.ProviderTitleHistory.TitleCode,
dbo.ProviderMaster.LastName,
dbo.ProviderMaster.PreferredName,
dbo.ProviderTitleHistory.SiteLocationName,
SiteLocationLookupFlat.RegionalDirectorName,
dbo.ProviderMaster.ProviderMasterID
FROM
dbo.ProviderTitleHistory,
dbo.ProviderMaster,
SiteLocationLookupFlat,
dbo.StaffHistory,
dbo.ProviderSiteLocationStaffGroup
WHERE
( dbo.ProviderMaster.ProviderMasterID=dbo.StaffHistory.ProviderMasterID )
AND ( dbo.ProviderTitleHistory.ProviderMasterID=dbo.StaffHistory.ProviderMasterID and dbo.ProviderTitleHistory.StaffGroup=dbo.StaffHistory.StaffGroup )
AND ( dbo.ProviderSiteLocationStaffGroup.ProviderMasterID=dbo.StaffHistory.ProviderMasterID and dbo.ProviderSiteLocationStaffGroup.StaffGroup=dbo.StaffHistory.StaffGroup )
AND ( SiteLocationLookupFlat.SiteLocationID=dbo.ProviderSiteLocationStaffGroup.SiteLocationID )
AND (
dbo.ProviderTitleHistory.ActiveFlag = 'Y'
AND dbo.ProviderTitleHistory.TitleCode = 'MD '
)
ORDER BY
1
i tried a case statement and an if statement to have the 2nd and 3rd MPID's in the report only pull if the title code was RD (regional director) but kept getting an error. Can anyone sugest a fix.
If i have made you head explode please let me know.
Thanks
Ivan