I have this sql query:
select COUNT(batch_id) AS cc FROM tbl_associate_593932 WHERE induction_result>50 GROUP BY batch_id
This query executes correctly with only one column cc. Now I want to get max value out of the values in this column. I tried something like this:
select max (cc) from (select COUNT(batch_id) AS cc FROM tbl_associate_593932 WHERE induction_result>50 GROUP BY batch_id);
However in SQL Server, it gave me error: Incorrect syntax near ‘;’. Expecting AS, ID or Quoted_ID
and another error Invalid column name ‘cc’.
How can I do this in SQL Server. Can same be done in Oracle?
You can do this:
Or: