Simple SQL query:
(select e.lastName as Name, count(o.orderid) as numOrd from
Employees e join Orders o on e.employeeid=o.employeeid
group by e.lastName)
and result
Buchanan 42
Callahan 104
Davolio 123
Dodsworth 43
My question is how to achieve in SQL something like that:
let queryResult =
(select e.lastName as Name, count(o.orderid) as numOrd from
Employees e join Orders o on e.employeeid=o.employeeid
group by e.lastName)
and after that to write something like this, which will be the output:
select AVG(qr.numOrd) from queryResult qr
Is it possible without creating any new tables?