How to select last one week data from today's date

前端 未结 3 1774
一向
一向 2020-12-09 07:50

How to select week data (more precisely, last 7 days data) from the current date in the fastest way as I have millions or rows in the table. I have a time stamp of created_d

3条回答
  •  一向
    一向 (楼主)
    2020-12-09 08:15

    1. The query is correct

    2A. As far as last seven days have much less rows than whole table an index can help

    2B. If you are interested only in Created_Date you can try using some group by and count, it should help with the result set size

提交回复
热议问题