with max_budget(value) as ( selectmax(budget) from department ) select budget from department, max_budget where department.budget=max_budget.value;
1 2 3 4 5 6 7 8 9 10 11 12 13
mysql> with max_budget(value) as ( select max(budget) from department ) select budget from department, max_budget where department.budget=max_budget.value; +--------+ | budget | +--------+ | 120000 | +--------+ 1 row inset
with dept_total(dept_name,value) as ( select dept_name, sum(salary) from instructor groupby dept_name ), dept_total_avg(value) as ( selectavg(value) from dept_total ) select dept_name from dept_total,dept_total_avg where dept_total.value>=dept_total_avg.value;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
mysql> with dept_total(dept_name,value) as ( select dept_name, sum(salary) from instructor group by dept_name ), dept_total_avg(value) as ( select avg(value) from dept_total ) select dept_name from dept_total,dept_total_avg where dept_total.value>=dept_total_avg.value; +------------+ | dept_name | +------------+ | Comp. Sci. | | Finance | | Physics | +------------+ 3 rows inset