Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 SQL 过程很陌生。我有一个要求,我需要根据过去的日期收集每周报告。
我有 2 列说名称和时间戳。
现在,该报告详细说明了在一周的一天中找到该名称的次数。
我可以每天获取它,但不确定是否可以每周获取它。
任何帮助表示赞赏。
您没有指定 RDBMS。但是,SQL 查询很容易支持您想要做的事情:
select name, sum(case when timestamp "during the time period" then 1 else 0 end) from t group by name
我将“期间”放在引号中,因为这因数据库而异,您并没有真正阐明您的意思。不过,建议是在 SQL 中执行此操作。