我们有一台24x7全天候运行的机器.每天我都会报告每小时生产的件数.在我们的例子中,一个工作日意味着'2015-06-16 06:00:00'到'2015-06-17 06:00:00'.
这是我的代码:
select date_trunc('hour', t_el_eventlog.eventtime at time zone 'CET') as hours,
count (distinct t_el_eventlog.serialnumber) as count
from t_el_eventlog
where eventtime at time zone 'CET' between '2015-06-16 06:00:00'
and '2015-06-17 06:00:00'
and sourceid = '44'
group by hours
order by hours asc
Run Code Online (Sandbox Code Playgroud)
我的Postgres版本:"PostgreSQL 9.4.1,由Visual C++编译构建1800,32位"
我正在处理的两列数据类型:
eventtime timestamp without time zone
sourceid integer NOT NULL
Run Code Online (Sandbox Code Playgroud)时区是"欧洲/柏林".
通过上面的查询,我得到了我想要的信息,但我必须每天更改日期.是否可以将该now()
功能用作我的情况的默认值,这样我就不必每天手动更改日期?
我想将一个完整的数据框导出到一个已经在数据库(postgresql)中创建并包含类似数据的表中.
我发现几个问题解释有关dbwrite表(.... overwrite = TRUE),我不想覆盖我表中已经存在的数据.我只想用r console中的数据框更新我的表.
谁能让我知道我怎么能这样做..
这样的事情
dbInsertTable(con, df, tablename = "MyTable")
Run Code Online (Sandbox Code Playgroud) #qcc package(spc charts)
library(qcc)
A <- c(10,20,30)
B <- c(25,35,44)
par(mfrow = c(2, 1))
qcc(A,type="xbar.one")
qcc(B,type="xbar.one")
Run Code Online (Sandbox Code Playgroud)
问题是:chart(B) 正在替换第二行中的 chart(A) 而不是 positiong。有人请让我知道如何克服这些问题
表 1(1422 行)
sn1 | dateee | shift | linee
---------+---------------------+-------+-------
8419404 | 2015-02-27 09:45:50 | D | 2
8419383 | 2015-02-27 09:46:10 | D | 2
8419410 | 2015-02-27 09:46:40 | D | 2
8419385 | 2015-02-27 09:50:40 | D | 2
8419412 | 2015-02-27 09:50:50 | D | 2
8419390 | 2015-02-27 09:51:30 | D | 2
8419414 | 2015-02-27 09:52:00 | D | 2
8419387 | 2015-02-27 09:52:20 | D | 2
8419416 | 2015-02-27 09:52:50 | …
Run Code Online (Sandbox Code Playgroud)