Versions Compared

Key

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

For Discussion 


#

Comment
Owner
1Should TrustName and Number be unique ?Yes.Alistair Pringle (Unlicensed)

Break down of TrustNumber and TrustName NULL or NOT NULL values;

Code Block
sql
sql
select CASE WHEN TrustName IS NULL THEN 'NULL' ELSE 'NOT NULL' END TrustName, 
	   CASE WHEN trustNumber IS NULL THEN 'NULL' ELSE 'NOT NULL' END trustNumber, status, count(*) 
from [HEELIVE].[vwTrust]
group by CASE WHEN TrustName IS NULL THEN 'NULL' ELSE 'NOT NULL' END, CASE WHEN trustNumber IS NULL THEN 'NULL' ELSE 'NOT NULL' END, status


TrustNametrustNumberstatusRowCount
NOT NULLNOT NULLCurrent824
NULLNULLCurrent3
NULLNOT NULLCurrent19
NOT NULLNULLCurrent15
NOT NULLNULLInactive107
NULLNULLInactive6
NULLNOT NULLInactive22
NOT NULLNOT NULLInactive1273


Total2269


There are 19 Trust rows that are duplicated

Code Block
sql
sql
select TrustName, trustNumber, status, count(*) 
from [HEELIVE].[vwTrust]
group by TrustName, trustNumber, status
having count(*) > 1
order by 3, 4 desc


TrustNametrustNumberstatusRowCount
NULLNULLCurrent3
NULLBATHCurrent2
NULLBRISCurrent2
NULLGLOSCurrent2
NULLQD6Current2
NULLQDXCurrent2
NULLSOMCurrent2
NULLSWICurrent2
UndefinedUNDCurrent2
Wiltshire Council817Current2
Worcestershire PCTNULLCurrent2
NULLNULLInactive6
NULLZZZZZInactive3
NULLRECRUInactive3
NULLRT5EJInactive2
NULLMATInactive2
John Coupland HospitalNULLInactive2
ZZZ John Coupland HospitalNULLInactive2
NULL??RWMInactive2

Trust Name and Number duplicates

Code Block
sql
sql
select lo.LocalOfficeName, t.*
from [HEELIVE].[vwTrust] as t
left join [HEELIVE].[vwLocalOffice] as lo ON (lo.itemtype = 'Trust' and lo.UniqueID = t.TrustID)
where status = 'Current'
and ISNULL(TrustName, -1) + ISNULL(trustNumber,-2) in (select ISNULL(TrustName, -1) + ISNULL(trustNumber,-2)
													   from [HEELIVE].[vwTrust]
													   where status = 'Current'
													   group by TrustName, trustNumber
													   having count(*) > 1)
order by trustName, TrustNumber


LocalOfficeNameRecordOriginSTATUSTrustNameTrustKnownAsTrustNumberDeaneryLETBTrustID
HESWHEELIVECurrentNULLBath VTSBATHSevern Local Office - HESW36090056
NULLHEELIVECurrentNULLBath VTSBATHSevern Local Office - HESW32948533
HESWHEELIVECurrentNULLBristol VTSBRISSevern Local Office - HESW36090050
NULLHEELIVECurrentNULLBristol VTSBRISSevern Local Office - HESW32948605
HESWHEELIVECurrentNULLGloucestershire VTSGLOSSevern Local Office - HESW36090059
NULLHEELIVECurrentNULLGloucestershire VTSGLOSSevern Local Office - HESW32948528
HENEHEELIVECurrentNULLHealth Education South WestNULLNULL29034540
HESWHEELIVECurrentNULLDeferred TraineeNULLSevern Local Office - HESW36090055
NULLHEELIVECurrentNULLDeferred TraineeNULLSevern Local Office - HESW33643819
HESWHEELIVECurrentNULLS & W Devon Health AuthorityQD6Peninsula Local Office - HESW36090058
NULLHEELIVECurrentNULLS & W Devon Health AuthorityQD6Peninsula Local Office - HESW33643809
HESWHEELIVECurrentNULLNorth and East Devon Health AuthorityQDXPeninsula Local Office - HESW36090054
NULLHEELIVECurrentNULLNorth and East Devon Health AuthorityQDXPeninsula Local Office - HESW32948568
HESWHEELIVECurrentNULLSomerset VTSSOMSevern Local Office - HESW36090057
NULLHEELIVECurrentNULLSomerset VTSSOMSevern Local Office - HESW32948661
HESWHEELIVECurrentNULLSwindon VTSSWISevern Local Office - HESW36090052
NULLHEELIVECurrentNULLSwindon VTSSWISevern Local Office - HESW32948634
HEEMHEELIVECurrentUndefinedUndefinedUNDHealth Education England West Midlands275385639
HEEOEHEELIVECurrentUndefinedUndefinedUNDHealth Education England West Midlands275385639
HELASEHEELIVECurrentUndefinedUndefinedUNDHealth Education England West Midlands275385639
HESWHEELIVECurrentUndefinedUndefinedUNDHealth Education England West Midlands275385639
HEWMHEELIVECurrentUndefinedUndefinedUNDHealth Education England West Midlands275385639
HEWTVHEELIVECurrentUndefinedUndefinedUNDNULL275385640
HESWHEELIVECurrentWiltshire CouncilWiltshire Council817Severn Local Office - HESW32948539
HEWTVHEELIVECurrentWiltshire CouncilWiltshire Council (817 / 1-AHNGU3)817Health Education England Wessex276017384
HESWHEELIVECurrentWorcestershire PCTWorcestershire PCTNULLNULL36093376
NULLHEELIVECurrentWorcestershire PCTWorcestershire PCTNULLNULL32948547

Red rows above signify that the LocalOffice field has not been set for these trust rows, and probably being done to aid the filtering out of these duplicated Trusts