Error in SQL QUERY

Asked

Viewed 57 times

1

SELECT COUNT(*) AS total
FROM table 
GROUP BY (YEAR_MONTH FROM data)
ORDER BY (YEAR_MONTH FROM data) ASC

_YEAR_MONTH_ and I don’t know why

inserir a descrição da imagem aqui

  • This SQL was done in which database? Put the error message to facilitate the identification of the problem.

  • 1

    The EXTRACT function is not missing? EXTRACT(YEAR_MONTH FROM data)

1 answer

4


By the syntax I believe you’re using mysql. So I believe you’ve forgotten the extract.

SELECT COUNT(*) AS total
FROM table 
GROUP BY EXTRACT(YEAR_MONTH FROM data)
ORDER BY EXTRACT(YEAR_MONTH FROM data) ASC
  • 1

    I just saw that @Emanuelf commented the same that I answered here, so try it yourself.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.