【问题标题】:How to count the number of rows updated, on each day/date, for a given range of dates如何计算给定日期范围内每天/日期更新的行数
【发布时间】:2016-10-13 19:16:41
【问题描述】:

我的 Oracle 表的列包含每行上次更新的日期(时间戳)。列定义为时间戳(6)。

我需要计算给定日期范围内每天/日期更新的行数。 示例:2016 年 9 月的每一天,更新了多少行?

示例输出:

Date                           Count                My Remarks
=================              =======              ====================
September 1, 2016                 20                20 rows updated on 9/1/16
September 2, 2016                 31                31 rows updated on 9/2/16
September 3, 2016                 14                14 rows updated on 9/3/16
September 4, 2016                 43                43 rows updated on 9/4/16
September 5, 2016                 89                89 rows updated on 9/5/16
....
September 30, 2016                74                74 rows updated on 9/30/16

谁能帮我查询一下?

提前致谢, 丰富

【问题讨论】:

  • MyRemarks 列的用途是什么?它将如何填充?
  • 对于在不同日期内多次更新的行,统计信息将是错误的。

标签: oracle function count


【解决方案1】:

一个选项是

SELECT trunc(timestamp_column)
      ,count(*)
  FROM your_table
 GROUP BY trunc(timestamp_column)

当然,您可以为“我的备注”列创建一个字符串,将这两列中的信息组合起来,如果这就是该列所做的一切(在这种情况下,我不确定您为什么要打扰.. .).

【讨论】:

    猜你喜欢
    • 2021-05-01
    • 1970-01-01
    • 2011-02-05
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 2010-09-19
    相关资源
    最近更新 更多