Home > database >  Regarding the group by usage
Regarding the group by usage

Time:09-19

Select department number, t. t. department name, avg (t. salary) "average wage" from
(
The select E.d eptno department number, D.d name "department name," E.s al "wages"
The from emp "E"
The join dept "D" on d.d eptno=e.d eptno
Where e.s al & gt;=1500
"T"
Group by t. department number,

Emp dept for orical sample table, last line of code if remove the "t. department name" is an error, why? Department name is common feature in the group, and why can't we get rid of? Is because he is from the dept table? Strives for the bosses to solve, thank you!

CodePudding user response:

Had better send the table structure, easy to do test,

CodePudding user response:

reference 1st floor chinadragonfly response:
had better send the table structure, easy to do the experiment test,

Link: https://pan.baidu.com/s/1u7UP6Eai6BSPy47WSzSa1w extraction code: eug9
In the three tables

CodePudding user response:

D.d name not is the department number, you want to be in the select render, you must group by merging to heavy,
In a subset of queries, it is a query field,

CodePudding user response:

If you want to display department name, you can keep the demerit of group by a table, then a table, so that you can
  • Related