Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
sql
sql
select p.status, lop.LocalOfficeName, p.ProgrammeNumber, p.ProgrammeName, p.ManagingDeanery, 
	   case when p.ManagingDeanery = 'Health Education England North West' THEN 'HENW'
			when p.ManagingDeanery = 'Health Education England West Midlands' THEN 'HEWM'
			when p.ManagingDeanery = 'Health Education England Yorkshire and the Humber' THEN 'HEYH'
			when p.ManagingDeanery = 'Health Education England North East' THEN 'HENE'
			when p.ManagingDeanery = 'Health Education England East of England' THEN 'HEEOE'
			when p.ManagingDeanery IN ('Health Education England South West', 
									   'Peninsula Local Office - HESW', 
									   'Severn Local Office - HESW') THEN 'HESW'
			when p.ManagingDeanery IN ('Health Education England East Midlands', 
									   'Yorkshire & Humber Deanery (North East)') THEN 'HEEM'
			when p.ManagingDeanery IN ('Health Education England Kent, Surrey and Sussex', 
									   'London LETBs', 
								       'Health Education England North West London', 
								       'Health Education England North Central and East London', 
								       'Health Education England South London') THEN 'HELASE'
			when p.ManagingDeanery IN ('Health Education England Wessex', 'Health Education England Thames Valley') THEN 'HEWTV'
			else 'UNKNOWN'
		end as mapped_lo
from [HEELIVE].[vwProgramme] as p
join [HEELIVE].[vwLocalOffice] as lop on (lop.ItemType = 'Programme' and lop.UniqueID = p.programmeid)
--where status = 'Current'
--and managingdeanery is not null
order by 6,1,2 desc

select p.status, lop.LocalOfficeName, p.ManagingDeanery, 
	   case when p.ManagingDeanery = 'Health Education England North West' THEN 'HENW'
			when p.ManagingDeanery = 'Health Education England West Midlands' THEN 'HEWM'
			when p.ManagingDeanery = 'Health Education England Yorkshire and the Humber' THEN 'HEYH'
			when p.ManagingDeanery = 'Health Education England North East' THEN 'HENE'
			when p.ManagingDeanery = 'Health Education England East of England' THEN 'HEEOE'
			when p.ManagingDeanery IN ('Health Education England South West', 
									   'Peninsula Local Office - HESW', 
									   'Severn Local Office - HESW') THEN 'HESW'
			when p.ManagingDeanery IN ('Health Education England East Midlands', 
									   'Yorkshire & Humber Deanery (North East)') THEN 'HEEM'
			when p.ManagingDeanery IN ('Health Education England Kent, Surrey and Sussex', 
									   'London LETBs', 
								       'Health Education England North West London', 
								       'Health Education England North Central and East London', 
								       'Health Education England South London') THEN 'HELASE'
			when p.ManagingDeanery IN ('Health Education England Wessex', 'Health Education England Thames Valley') THEN 'HEWTV'
			else 'UNKNOWN'
		end as mapped_lo, count(*) as rc
from [HEELIVE].[vwProgramme] as p
join [HEELIVE].[vwLocalOffice] as lop on (lop.ItemType = 'Programme' and lop.UniqueID = p.programmeid)
--where status = 'Current'
--and managingdeanery is not null
--order by 6,1,2 desc
group by p.status, lop.LocalOfficeName, p.ManagingDeanery, 
	   case when p.ManagingDeanery = 'Health Education England North West' THEN 'HENW'
			when p.ManagingDeanery = 'Health Education England West Midlands' THEN 'HEWM'
			when p.ManagingDeanery = 'Health Education England Yorkshire and the Humber' THEN 'HEYH'
			when p.ManagingDeanery = 'Health Education England North East' THEN 'HENE'
			when p.ManagingDeanery = 'Health Education England East of England' THEN 'HEEOE'
			when p.ManagingDeanery IN ('Health Education England South West', 
									   'Peninsula Local Office - HESW', 
									   'Severn Local Office - HESW') THEN 'HESW'
			when p.ManagingDeanery IN ('Health Education England East Midlands', 
									   'Yorkshire & Humber Deanery (North East)') THEN 'HEEM'
			when p.ManagingDeanery IN ('Health Education England Kent, Surrey and Sussex', 
									   'London LETBs', 
								       'Health Education England North West London', 
								       'Health Education England North Central and East London', 
								       'Health Education England South London') THEN 'HELASE'
			when p.ManagingDeanery IN ('Health Education England Wessex', 'Health Education England Thames Valley') THEN 'HEWTV'
			else 'UNKNOWN'
		end


statusLocalOfficeNameManagingDeanerymapped_lorc
CurrentHEEMHealth Education England East MidlandsHEEM88
CurrentHEEMHealth Education England Yorkshire and the HumberHEYH2
CurrentHEEOEHealth Education England East of EnglandHEEOE109
CurrentHEEOELondonUNKNOWN1
CurrentHELASEHealth Education England Kent, Surrey and SussexHELASE57
CurrentHELASEHealth Education England North West LondonHELASE46
CurrentHELASEHealth Education England North Central and East LondonHELASE62
CurrentHELASEHealth Education England South LondonHELASE64
CurrentHELASEHealth Education England WessexHEWTV5
CurrentHELASELondon LETBsHELASE23
CurrentHENEHealth Education England North EastHENE94
CurrentHENEHealth Education England Yorkshire and the HumberHEYH6
CurrentHENWHealth Education England North WestHENW197
CurrentHESWHealth Education England South WestHESW148
CurrentHEWMDefence Postgraduate Medical DeaneryUNKNOWN1
CurrentHEWMHealth Education England West MidlandsHEWM165
CurrentHEWTVHealth Education England Thames ValleyHEWTV77
CurrentHEWTVHealth Education England WessexHEWTV74
CurrentHEYHNULLUNKNOWN33
CurrentHEYHHealth Education England Yorkshire and the HumberHEYH75
InactiveHEEMNULLUNKNOWN363
InactiveHEEMHealth Education England East MidlandsHEEM4
InactiveHEEMYorkshire & Humber Deanery (North East)HEEM1
InactiveHEEOEHealth Education England East of EnglandHEEOE1
InactiveHELASENULLUNKNOWN15698
InactiveHELASEHealth Education England Kent, Surrey and SussexHELASE22
InactiveHELASEHealth Education England North West LondonHELASE3
InactiveHELASEHealth Education England North Central and East LondonHELASE3
InactiveHELASEHealth Education England South LondonHELASE4
InactiveHELASELondon LETBsHELASE82
InactiveHENEHealth Education England North EastHENE1
InactiveHENWHealth Education England North WestHENW7
InactiveHESWNULLUNKNOWN637
InactiveHESWPeninsula Local Office - HESWHESW1
InactiveHESWSevern Local Office - HESWHESW9
InactiveHEWTVNULLUNKNOWN52
InactiveHEWTVHealth Education England Thames ValleyHEWTV15
InactiveHEWTVHealth Education England WessexHEWTV12
InactiveHEYHNULLUNKNOWN142