Suppose we have an Emp table with EmpId, Manager, Subb as three columns.
Manager is 1 when EmpId is manager, similarly for subb.
Require number of manager and subb from table.
Can we combine these two queries into a single SELECT query? (want to scan table just once)
select count(*) as ManagerNumber from Emp where Manager=1
select count(*) as Subordinate from Emp where Subb=1.
You can do this:
And it is SQL ANSI standard, it will work in all RDBMS.