SQL Server “cannot perform an aggregate function on an expression containing an aggregate or a subquery”, but Sybase can

One option is to put the subquery in a LEFT JOIN: select sum ( t.graduates ) – t1.summedGraduates from table as t left join ( select sum ( graduates ) summedGraduates, id from table where group_code not in (‘total’, ‘others’ ) group by id ) t1 on t.id = t1.id where t.group_code=”total” group by t1.summedGraduates … Read more

Difference between Subquery and Correlated Subquery

Above example is not Co-related Sub-Query. It is Derived Table / Inline-View since i.e, a Sub-query within FROM Clause. A Corelated Sub-query should refer its parent(main Query) Table in it. For example See find the Nth max salary by Co-related Sub-query: SELECT Salary FROM Employee E1 WHERE N-1 = (SELECT COUNT(*) FROM Employee E2 WHERE … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)