我有一个commits包含以下列的数据库表:
id | author_name | author_email | author_date(timestamp)| total_lines
样本内容如下:
1 | abc | abc@xyz.com | 2013-03-24 15:32:49 | 1234
2 | abc | abc@xyz.com | 2013-03-27 15:32:49 | 534
3 | abc | abc@xyz.com | 2014-05-24 15:32:49 | 2344
4 | abc | abc@xyz.com | 2014-05-28 15:32:49 | 7623
Run Code Online (Sandbox Code Playgroud)
我想得到如下结果:
id | name | week | commits
1 | abc | 1 | 2
2 | abc | 2 | 0
Run Code Online (Sandbox Code Playgroud)
我在网上搜索类似的解决方案但无法获得任何有用的解决方案.
我试过这个查询:
SELECT date_part('week', author_date::date) AS …Run Code Online (Sandbox Code Playgroud) 我是新手R,我正在尝试使用 RStudio 连接到 PostgreSQL。
我已经安装RPostgreSQL并尝试了以下代码:
> library("DBI", lib.loc="~/R/win-library/3.2")
> library("RPostgreSQL", lib.loc="~/R/win-library/3.2")
> con <- dbConnect(dbDriver("PostgreSQL"), dbname="Delta", user="postgres")
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect postgres@local on dbname "Delta"
Run Code Online (Sandbox Code Playgroud)
由于某种原因我无法连接到数据库。我想解决这个问题很长时间,但不知道如何解决。