sql - 使用复合 sql 语句
问题描述
我正在使用https://try.askgit.com/获取有关回购的统计信息。现在我需要获取上个月(6/21)的提交数量,我将如何使用 sum 函数来做到这一点?
我有这个语句,它查询每个作者当月的提交次数,然后我只对 count 列求和,但我不确定如何在 SQL 中执行此操作:
SELECT author_name, count(*)
FROM commits
WHERE '2021-06-01T00:00:00.000' <= author_when AND author_when <= '2021-06-30T00:00:00.000'
GROUP BY author_name
ORDER BY count(*) DESC
解决方案
假设您不想按作者计数,您可以这样做:
SELECT count(*) as Count
FROM commits
WHERE '2021-06-01T00:00:00.000' <= author_when AND author_when < '2021-07-01T00:00:00.000'
推荐阅读
- ssh - 如何在有或没有跳转主机的情况下运行相同的剧本和库存?
- javascript - Bazel 自动为 ts_library 生成依赖项
- python-3.x - Anaconda 无法在 Windows10 上创建进程
- python - 点击计数/页面查看功能 Django 应用程序
- site-prism - 是否有关于使用部分的 Siteprism 最佳实践
- java - 遍历多维数组后,如何仅打印一次消息?
- android - 键入时替换 Edittext 中的字符
- python - 如何转换 PySpark Word2Vec 模型并加载它如何 gensim Word2Vec 模型?
- python - 检查子进程是否中断,如果为真则重新启动
- gnome - Gnome 3 禁用“解锁私钥”模式 GUI