Skip to content

Instantly share code, notes, and snippets.

@grgaortiz
Created August 26, 2016 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grgaortiz/4a5813abb5bb035478a6e934151adefc to your computer and use it in GitHub Desktop.
Save grgaortiz/4a5813abb5bb035478a6e934151adefc to your computer and use it in GitHub Desktop.
SELECT
l.LocationAddress1 AS location_address,
l.LocationAddress2 AS location_address_two,
l.LocationZip AS location_zip,
l.LocationPrimaryPhone AS location_phone,
l.LocationSecondaryPhone AS location_secondary_phone,
c.City AS location_city,
s.StateCode AS location_state,
co.County AS location_county,
pr.PracticeName AS practice_name,
pr.PracticeSk AS practice_code,
l.LocationSk AS location_id,
fnf.FacilityNonFacilityDesc AS location_facility,
pl.ProviderLocationSk AS providerLocationSk
FROM dir.Provider p
LEFT JOIN dir.ProviderLocation pl ON pl.ProviderSk = p.ProviderSk AND pl.RowOrder != '0'
LEFT JOIN dir.Location l ON l.LocationSk = pl.LocationSk
LEFT JOIN dir.City c ON c.CitySk = l.CitySk
LEFT JOIN dir.State s ON s.StateSk = l.StateSk
LEFT JOIN dir.County co ON co.CountySk = l.CountySk
LEFT JOIN dir.PracticeLocation prl ON prl.LocationSk = l.LocationSk
LEFT JOIN dir.Practice pr ON pr.PracticeSk = prl.PracticeSk
LEFT JOIN dir.FacilityNonFacility fnf ON fnf.FacilityNonFacilitySk = l.FacilityNonFacilitySk
WHERE p.ProviderSk = '1912' AND pl.RowStatusSk = '1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment