Hi,
I have two tables (Management and Employee).
The management table tracks the different management teams that have managed company X in past few years. Each management team is given an ID (i.e: managementnr), and each team has a CEO (namely ceoname).
The employee table tracks employees working for company X (basically just their names and which management team hired them)
Here is the SQL code:
CREATE TABLE EMPLOYEE(
EMPLOYEENAME VARCHAR2(15) NOT NULL,
HIRETEAM NUMBER(2),
PRIMARY KEY (EMPLOYEENAME)
);
CREATE TABLE MANAGEMENT(
MANAGEMENTNR NUMBER(2) NOT NULL,
CEONAME VARCHAR2(20) NOT NULL,
PRIMARY KEY (MANAGEMENTNR,CEONAME)
);
I'm trying to form an SQL query to get the managementNR in which the highest number of employees have been hired. I've tried using:
SELECT HIRETEAM,max(count(HIRETEAM))
from EMPLOYEE
group by HIRETEAM
but I keep getting:
ORA-00937: not a single-group group function
(I'm using Oracle)
After hours of Google-fu, I finally understand what this error means, however I still cannot think of any other way to form this query. I've tried using subqueries / joins, but still nothing. I'm very new to SQL in general. If anybody can help, I would be really grateful!
Thank you for your time =]
--Evan Lestrange