Jump to content
Fórum Script Brasil
  • 0

Agrupamento de dados personalizado


FabricioSilmeida

Question

ola eu uso o seguinte código para fazer uma busca e agrupar por hora,dia,sema,mês e ano o problema e que queria agrupar por quinzena e não consigo pois não tem DATE_FORMAT para quinzena para gerar a legenda e nem GROUP BY para quinzena para gerar o agrupamento

SELECT
    SUM(SL.sm_wats/SL.qt_dados)/1000 AS consumo, DATE_FORMAT(SL.dt_leitura,'%U') as legenda,COUNT(*) AS contagem
FROM sistema_ldevice AS SL
WHERE SL.cd_device = ".$id_objeto." AND SL.dt_leitura like '%".$data[0].'-'.$data[1]."%' AND SL.sm_wats != 0
GROUP BY WEEK(SL.dt_leitura)
ORDER BY legenda ASC

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...