Error running PostgreSQL query from SQL Server 2016
select main.ResellerId, main.vCompanyName , x.&quot;count&quot;, x.vReportTypeName
from wlt_tblReseller AS main 
LEFT JOIN   ( select (count (ipkReportTypeId)) AS &quot;count&quot;, vReportTypeName, RootResellerId  
              from wlt_tblReseller _all 
              inner join wlt_tblClient clients  on clients.ifkParentResellerId = _all.ResellerId
              inner join wlt_tblReport_CompanyMaster reporslogs on reporslogs.ifkCompanyId = clients.ClientId
              inner join wlt_tblReports_TypeMaster rpt_types on rpt_types.ipkReportTypeId = reporslogs.ifkReportTypeId 
              where 
                    rpt_types.bStatus =1 
                and bIsStatic =1 
                and vReportTypeName  is not null
              group by ipkReportTypeId,vReportTypeName
            ) AS x ON x.RootResellerId = main.ResellerId
WHERE IsMiniReseller = 0 
  and ResellerId &lt;&gt; 1  
  and vReportTypeName is not null 
order by  vCompanyName desc 

PS. Add table aliases to all column names for to remove potential ambiguity...