SQL:需要帮助编写查询,该查询将显示此人是否有职位较低的人

发布于 2024-12-08 17:52:12 字数 350 浏览 1 评论 0原文

我正在尝试编写一个查询,该查询将显示该人是否有职位较低的人

SELECT Count(job)
FROM emp 
GROUP BY job
HAVING job < 'MANAGER'; 

是否有人愿意帮助我解决这个问题?

干杯

-Jay

我的问题的答案应该是:

Number of subORD
---------------------                                                           
                    6    

I am trying write a query that will display if the person has anyone with a lower job position

SELECT Count(job)
FROM emp 
GROUP BY job
HAVING job < 'MANAGER'; 

Would anyone be kind enough to help me with this?

Cheers

-Jay

Answer to my question should be:

Number of subORD
---------------------                                                           
                    6    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

⊕婉儿 2024-12-15 17:52:12

怎么样:

SELECT COUNT(*) FROM (
SELECT Super
FROM Emp 
GROUP BY Super
HAVING Super IS NOT NULL)

How about:

SELECT COUNT(*) FROM (
SELECT Super
FROM Emp 
GROUP BY Super
HAVING Super IS NOT NULL)
天涯离梦残月幽梦 2024-12-15 17:52:12

怎么样

Select count(*) as Supers
FROM (
Select distinct e1.EmpNo
from Emp e1 join Emp e2 on e1.EmpNo = e2.Super)

What about

Select count(*) as Supers
FROM (
Select distinct e1.EmpNo
from Emp e1 join Emp e2 on e1.EmpNo = e2.Super)
听你说爱我 2024-12-15 17:52:12

假设您可以通过检查是否有其他员工将其 ID 作为“SUPER”来确定员工 A 是否有下属。

SELECT COUNT(*) FROM (
SELECT Super
FROM Emp
WHERE Super > 0
GROUP BY Super) AS Supervisors

Assuming that you can determine if employee A has subordinates by checking if any other employees include his ID as their "SUPER".

SELECT COUNT(*) FROM (
SELECT Super
FROM Emp
WHERE Super > 0
GROUP BY Super) AS Supervisors
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文