dongliang1996 2018-04-07 13:32
浏览 82

如何在PHP / SQL中显示当月的每周报告,并将其标记为“第1周,第2周等”。

How to display weekly report from current month in php/sql and label it as "Week 1, Week 2, etc..". Under Week 1 is the records of week 1 and so on...

Here's my current code that only displays the total number of record per week.

select count(*) as totalWeeklycomplaints
from tblcomplain group by week(dateposted);

Sample OUTPUT

  • 写回答

1条回答 默认 最新

  • doutang3815 2018-04-07 13:35
    关注

    If you want the week, include it as a column:

    select week(dateposted), count(*) as totalWeeklycomplaints
    from tblcomplain
    group by week(dateposted);
    

    Because weeks repeat in years, I would suggest that you also include the year:

    select year(dateposted), week(dateposted), count(*) as totalWeeklycomplaints
    from tblcomplain
    group by year(dateposted), week(dateposted);
    

    Other than that, I can't quite tell what you are asking for.

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程