I am trying to run a statement with a subquery and can not work out why I am getting the error: "missing FROM-clause entry for table "CompTypesDetais"
I have attached the SQL file in case it is not legibel from here. The statement follows:
SELECT * FROM
(SELECT DISTINCT "Contacts".*, "Offices"."OfficeID","Offices"."Name", "Company"."CompanyID" FROM ("Contacts"
LEFT JOIN "Offices" ON ("Offices"."OfficeID" = "Contacts"."OfficeID")
LEFT JOIN "Company" ON ("Offices"."CompanyID" = "Company"."CompanyID")
LEFT JOIN "AssetDetails" ON ("AssetDetails"."CompanyID" = "Company"."CompanyID")
LEFT JOIN "Asset" ON ("AssetDetails"."AssetID" = "Asset"."AssetID" ))) AS "NewCompany"
LEFT JOIN "CompTypesDetails" ON ("NewCompany"."CompanyID" = "CompTypesDetais"."CompanyID" )