MySQL中的组函数能否嵌套使用? 例如: select max(avg(salary)) from employee group by department_id;

MySQL中的组函数能否嵌套使用? 例如: select max(avg(salary)) from employee group by department_id;,第1张

也要参加分组

SELECT PT.PRES_NAME,PT.YRS_SERV,AVG(EN.VOTES)

FROM PRESIDENT PT,ELECTION EN

WHERE PT.PRES_NAME=EN.CANDIDATE AND PT.STATE_BORN='Texas'

GROUP BY PT.STATE_BORN,PT.PRES_NAME,PT.YRS_SERV

如果想让他们分组就这样

SELECT AVG(EN.VOTES)

FROM PRESIDENT PT,ELECTION EN

WHERE PT.PRES_NAME=EN.CANDIDATE AND PT.STATE_BORN='Texas'

GROUP BY PT.STATE_BORN

也要参加分组

SELECT PT.PRES_NAME,PT.YRS_SERV,AVG(EN.VOTES)

FROM PRESIDENT PT,ELECTION EN

WHERE PT.PRES_NAME=EN.CANDIDATE AND PT.STATE_BORN='Texas'

GROUP BY PT.STATE_BORN,PT.PRES_NAME,PT.YRS_SERV

如果不想让他们分组就这样

SELECT AVG(EN.VOTES)

FROM PRESIDENT PT,ELECTION EN

WHERE PT.PRES_NAME=EN.CANDIDATE AND PT.STATE_BORN='Texas'

GROUP BY PT.STATE_BORN


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8627006.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-19
下一篇 2023-04-19

发表评论

登录后才能评论

评论列表(0条)

保存