查询重用视图

时间:2017-12-10 04:13:16

标签: sql recursive-query

鉴于关系为complete <- function(directory, id = 1:332) { collectCounts = data.frame(id=numeric(), nobs=numeric()) for(i in id) { fileName = sprintf("%03d",i) fileLocation = paste(directory, "/", fileName,".csv", sep="") fileData = read.csv(fileLocation, header=TRUE) completeCount = sum(!is.na(fileData[,2]), na.rm=TRUE) collectCounts <- rbind(collectCounts, c(id=i, completeCount)) #print(completeCount) } colnames(collectCounts)[1] <- "id" colnames(collectCounts)[2] <- "nobs" print(collectCounts) } person(name, gender, father, mother)nameprimary key为值genderM,我该怎么办?在中编写递归视图以找到提及所有姐妹的列表?

1 个答案:

答案 0 :(得分:0)

假设姐妹的定义意味着父母双方都一样,那么它可以这么简单吗?

select t2.name
from table t1 join table t2 on t1.mother = t2mother
and t1.father = t2.father

where t1.name <> t2.name
and t2.gender = 'F'