-2

This is the table named employee.

This is the question and sample output

SELECT MONTH(EMP_HIREDDATE) AS “Hire Month”, COUNT(EMP_NUM) AS “No Of Employee” 
FROM EMPLOYEE
GROUP BY EMP_NUM;

The above command doesn't return the desired output.

I understand that COUNT(EMP_NUM) is not working because each employee is having a unique EMP_NUM but I've no idea what to do

Strawberry
  • 33,750
  • 13
  • 40
  • 57
zZzZ
  • 141
  • 2
  • 3
  • 10
  • 1
    Please don't use images. They are hard to read, and reproduce. Please read this link: [Why should I provide a Minimal Reproducible Example for a very simple SQL query?](https://meta.stackoverflow.com/q/333952/2469308) – Madhur Bhaiya Sep 27 '19 at 12:44
  • Just change your GROUP BY and set **GROUP BY MONTH(EMP_HIREDDATE)** – nacho Sep 27 '19 at 12:48
  • *"The above command doesn't return the desired output"* that query should have giving a error... Time to configure sql_mode ONLY_FULL_GROUP_BY if your MySQL version does support it.. – Raymond Nijland Sep 27 '19 at 13:03

1 Answers1

-1

Use this (Just Change Group by Clause)

  SELECT MONTH(EMP_HIREDDATE) AS “Hire Month”, COUNT(EMP_NUM) AS “No Of Employee” FROM EMPLOYEE GROUP BY MONTH(EMP_HIREDDATE);
Strawberry
  • 33,750
  • 13
  • 40
  • 57