SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE apollo_org_job_function ( department VARCHAR(64) ); INSERT INTO apollo_org_job_function VALUES ('Engineering'),('Engineering'), ('human_resources'),('human_resources'),('human_resources'),('human_resources'), ('entrepreneurship'); WITH data AS ( SELECT department, COUNT(*) as "no_people" FROM apollo_org_job_function GROUP BY department ORDER BY department ) SELECT JSON_AGG(JSON_BUILD_OBJECT(department, no_people)) as "dep_people" FROM data;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear