我得到了一张名为“宠物”的桌子。具有以下值
id | name | nickname | dateofborn |
1 | test | jhon | 2009 |
2 | test2| test | 2010 |
3 | mike | NULL | 2010 |
3 | jhon | testor | 2011 |
我想选择包含' test'的所有列。在name列或nickname列中的值,所以我有这个查询实际上不适合我:
SELECT * FROM pet WHERE name='test' OR nickname= 'test'
请注意,我确实希望测试值不是测试者。
答案 0 :(得分:0)
查询是对的,我认为你的表有些问题。
但请尝试如下:
USE [yourDB es: animals];
SELECT * FROM [yourDB].pet WHERE (name='test' OR nickname='test');
答案 1 :(得分:-1)
试试这个。
fn<-function(x){
s<-seq(from = as.POSIXct(x$start),
to = as.POSIXct(x$end)-1,by = "mins")
# here s is a sequence of all minutes in the given interval
df<-data.table(x$id,x$cat,s)
# return new data.table that contains each calendar minute for each id
# and categoryy of the original data
df
}
# run the function above for each row in the data.table
dd<-adply(dt,1,fn)
# extract the date from calendar minutes
dd[,day:=format(as.POSIXct(s,"%d.%m.%Y %H:%M%:%S"), "%d.%m.%Y")]
#calculate sum of all minutes of event for each day, id and category
dd[,.N,by=c("day","id","cat")][order(day,id,cat)]