我有一个包含3列的MySQL表:

  • id (作为主键)

  • amount (int)

  • data_time (bigint),其中 date_time 列存储unix时间戳 .

need a query when run it show me on output 24 row and each row contain 3 columns 如下所示:

------ column1 -------------------------------- column2 ---------- ---------------------------------- column3 -------

row1:0-1 所有 amount 列的总和在00:00到01:00的全天本小时的行数

row2:1-2 所有 amount 列的总和在01:00到02:00的整天时间这小时的行数

row3:2-3小时所有 amount 列的全天02:00到03:00 *这个小时的行数

....

row24:23-0 *所有 amount 列的总和,全天23:00到00:00 *这小时的行数

This query needs to run within the start and the end of the timestamp range and may contain few days then we need this data calc for all day on a mentioned hour.

例如,开始时间戳为1511296200,结束时为1512592140,差异为15天 .