拥有一个包含以下列的员工表
eid ename salary did
100 king 5000 DB
101 kochaar 7000 DB
102 jack 6000 JAVA
103 john 3000 JAVA
104 marry 6000 DB
表格中的o / p iz
did count(eid)
DB 3
JAVA 2
DB 3
JAVA 2
DB 3
我尝试使用union all,我不确定,如何实现tiz o / p。
答案 0 :(得分:1)
select did
, count(*) over (partition by did)
from YourTable
答案 1 :(得分:0)
select t1.did
, count(t1.*)
from table1 t1
group by t1.did