有沒有一種方法可以根據SQL中的另一個列類型對行數進行計數?如何根據SQL中的另一個列類型對行數進行計數
數據庫:
Department | Resource Type | People
===================================
HR | manager | john
| staff | jason
| staff | smith
IT | manager | wendy
| staff | emma
| staff | jay
| staff | cody
HR2 | manager | john
| staff | terry
| staff | mike
| staff | fry
預期輸出:
john, 5 employees
wendy, 3 employees
謝謝
在你的數據,什麼樣的列值(S)建立經理和員工員工之間的關係?我沒有看到任何。對於員工而言,「部門」專欄真的是「空」嗎? – sstan
部門列中缺少值。 – jarlh
您正在使用哪些DBMS? Postgres的?甲骨文? –