CREATE VIEW DAQERWGlobalDomain AS 
  SELECT
    a.*,
    f.name as dataElement,
    j.asBitData,
    j.genericPicture,
    j.isComplex,
    j.isSigned,
    j.isLOB,
    j.precision as numericPrecision,
    j.scale,
    j.strLength as stringLength,
    j.strVaryingFlag as stringVaryingCode,
    j.typeCode,
    j.vgSignFormat as vagSignFormat,
    p.contents as elementDescription,
    p.label as elementDescType,
    x.name as libraryName
  FROM
    OIDOVers a
    INNER JOIN DSDataElement_vrsn b ON a.OID=b.OID AND a.OVer=b.OVer
    LEFT OUTER JOIN TCVersionClass d ON d.OID=b.OID AND d.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject e ON e.OID=d.osrelTCSourceObjct
    LEFT OUTER JOIN adobjectFind g ON g.OID=b.pSimpleTypeDef AND
       g.className='DSLinkDataElmn2SmplType' AND
       g.contextRelease=a.contextRelease AND g.contextName=a.contextName
    LEFT OUTER JOIN ADLink h ON h.OID=g.OID AND h.OVer=g.OVer
    LEFT OUTER JOIN adobjectFind q ON q.OID=b.inLibrary AND
       q.className='ERWLibraryHasGlobalDomain' AND
       q.contextRelease=a.contextRelease AND q.contextName=a.contextName
    LEFT OUTER JOIN ADLink r ON r.OID=q.OID AND r.OVer=q.OVer
    LEFT OUTER JOIN FHCPath f ON f.OID=e.osrelNuPathId
    LEFT OUTER JOIN adobjectFind i ON i.OID=h.adTarget AND
       i.className='DSSimpleTypeDef' AND
       i.contextRelease=a.contextRelease AND i.contextName=a.contextName
    LEFT OUTER JOIN OIDOVers s ON s.OID=r.adSource AND  s.contextOID=a.contextOID
    LEFT OUTER JOIN TCVersionClass v ON v.OID=r.adSource AND v.OVer=r.OVer
    LEFT OUTER JOIN DSSimpleTypeDef j ON j.OID=i.OID AND j.OVer=i.OVer
    INNER JOIN ADObject k ON k.OID=b.OID AND k.OVer=b.OVer AND
     k.className='DSDataElement_version'
    LEFT OUTER JOIN TCSourceObject w ON w.OID=v.osrelTCSourceObjct
    LEFT OUTER JOIN ADLink_source l ON l.classAttr='ADAnnotatedObject.pAnnotationText' AND
      l.sourceOID=k.OID AND l.sourceOVer=k.OVer
    LEFT OUTER JOIN adobjectFind m ON m.OID=l.relOID AND m.OVer=l.relOVer AND
       m.className='ADLinkADAnnotObj2AnnotTxt' AND
       m.contextRelease=a.contextRelease AND m.contextName=a.contextName
    LEFT OUTER JOIN ADLink n ON n.OID=m.OID AND n.OVer=m.OVer
    LEFT OUTER JOIN FHCPath x ON x.OID=w.osrelNuPathId
    LEFT OUTER JOIN adobjectFind o ON o.OID=n.adTarget AND
       o.className='ADAnnotationText' AND
       o.contextRelease=a.contextRelease AND o.contextName=a.contextName
    LEFT OUTER JOIN ADAnnotationText p ON p.OID=o.OID AND p.OVer=o.OVer;

