outer-join

How to replicate a SAS merge

╄→гoц情女王★ 提交于 2019-12-02 09:48:22
I have two tables, t1 and t2: t1 person | visit | code1 | type1 1 1 50 50 1 1 50 50 1 2 75 50 t2 person | visit | code2 | type2 1 1 50 50 1 1 50 50 1 1 50 50 When SAS runs the following code: DATA t3; MERGE t1 t2; BY person visit; RUN; It generates the following dataset: person | visit | code1 | type1 | code2 | type2 1 1 50 50 50 50 1 1 50 50 50 50 1 1 50 50 50 50 1 2 75 50 I want to replicate this process in SQL, and my idea was to use a full-outer-join. This works unless there are duplicate rows. When we have duplicate rows like in the above example, a full outer join produces the following

Doing a left join with old style joins

天大地大妈咪最大 提交于 2019-12-02 08:57:00
So I'm currently transcribing OracleSQL into a new PostgreSQL database. While I'm translating Oracle's (+) joins to LEFT OUTER JOIN s, this works very well. Except when combined with old style joins. Take this OracleSQL for example: SELECT * FROM table1, table2 alias1, table2 alias2, table2 alias3, table3, table4, table5, table6 table6alias WHERE table1.id_table3 = alias1.id_table3 AND table1.id_table4 = alias2.id_table4 AND table1.id_table3 = table3.id_table3 AND table1.id_table4 = table4.id_table4 AND table1.id_table5 = table5.id_table5 AND table1.table1_id_table3_sender = alias3.id_table3 (

Java: how to access outer class's instance variable by using “this”?

爱⌒轻易说出口 提交于 2019-12-02 03:57:46
问题 I have a static inner class, in which I want to use the outer class's instance variable. Currently, I have to use it in this format "Outerclass.this.instanceVariable", this looks so odd, is there any easier way to access the instance field of the outer class? Public class Outer { private int x; private int y; private static class Inner implements Comparator<Point> { int xCoordinate = Outer.this.x; // any easier way to access outer x ? } } 回答1: A static nested class cannot reference the outer

using outer function to get a table of values returned by a user defined function

白昼怎懂夜的黑 提交于 2019-12-02 03:09:59
问题 I am a newbie in R and trying to understand the vector way of processing rather than looping. I need help with how to create a table of values using outer function and a user defined function. Following is a simple function which gives price of a trivial bond bp = function(y, n=1, c=0, fv=100, freq=2){ per = 1:(n*freq) cf = rep(c/freq, n*freq) cf[length(cf)] = cf[length(cf)] + fv df = 1/(1+y/freq)^per cf %*% df } I would like to create a table of bond prices for a vector of yields, n and a

Java: how to access outer class's instance variable by using “this”?

可紊 提交于 2019-12-02 01:31:46
I have a static inner class, in which I want to use the outer class's instance variable. Currently, I have to use it in this format "Outerclass.this.instanceVariable", this looks so odd, is there any easier way to access the instance field of the outer class? Public class Outer { private int x; private int y; private static class Inner implements Comparator<Point> { int xCoordinate = Outer.this.x; // any easier way to access outer x ? } } A static nested class cannot reference the outer class instance because it's static , there is no related outer class instance. If you want a static nested

outer join in MS Excel

痴心易碎 提交于 2019-12-01 21:26:38
问题 do you have an idea how to join two tables with the outer join ? Know to do this in SQL, but I need Excel now. I have a list of all employees in one column I have a table of task for every employee. I would like to create a function, that will populate this table with missing employees. Table 1 - list of all employees Fernando Hector Vivian Ivan Table 2 - list of actual tasks Fernando, task A, 5 hours Vivian, task B, 8 hours Result I would like to achieve Fernando, task A, 5 hours Vivian,

How to replace a complex SQL MINUS query with LEFT OUTER JOIN equivalent

▼魔方 西西 提交于 2019-12-01 20:07:42
问题 Trying to figure how how to replace the following, with equivalent left outer join: select distinct(a.some_value) from table_a a, table_b b where a.id = b.a_id and b.some_id = 123 and b.create_date < '2014-01-01' and b.create_date >= '2013-12-01' MINUS select distinct(a.some_value) from table_a a, table_b b where a.id = b.a_id and b.some_id = 123 and b.create_date < '2013-12-01' Can not do "NOT IN", as the second query has too much data. 回答1: SELECT * FROM ( select distinct(a.some_value) from

How to replace a complex SQL MINUS query with LEFT OUTER JOIN equivalent

拥有回忆 提交于 2019-12-01 19:14:27
Trying to figure how how to replace the following, with equivalent left outer join: select distinct(a.some_value) from table_a a, table_b b where a.id = b.a_id and b.some_id = 123 and b.create_date < '2014-01-01' and b.create_date >= '2013-12-01' MINUS select distinct(a.some_value) from table_a a, table_b b where a.id = b.a_id and b.some_id = 123 and b.create_date < '2013-12-01' Can not do "NOT IN", as the second query has too much data. SELECT * FROM ( select distinct(a.some_value) from table_a a, table_b b where a.id = b.a_id and b.some_id = 123 and b.create_date < '2014-01-01' and b.create

outer join in MS Excel

南笙酒味 提交于 2019-12-01 19:08:11
do you have an idea how to join two tables with the outer join ? Know to do this in SQL, but I need Excel now. I have a list of all employees in one column I have a table of task for every employee. I would like to create a function, that will populate this table with missing employees. Table 1 - list of all employees Fernando Hector Vivian Ivan Table 2 - list of actual tasks Fernando, task A, 5 hours Vivian, task B, 8 hours Result I would like to achieve Fernando, task A, 5 hours Vivian, task B, 8 hours Hector, , 0 hours Ivan, , 0 hours Thanks a lot for any ideas. There is indeed such a thing

R pairwise product

只谈情不闲聊 提交于 2019-12-01 17:45:22
I'm trying to get the pairwise products of a vector, say a = c(1,2,3,4) What I'm trying to get is 2,3,4,6,8,12 (in that order). I've tried using outer: outer(1:4,2:4) and that gives me a matrix that includes the products I want but I'm not sure how to extract them from the matrix in a way that scales to vectors of higher dimensions. Thanks! combn() is nice for this sort of thing: a <- 1:4 combn(a, m = 2, FUN = prod) # [1] 2 3 4 6 8 12 lower.tri selects them in that order: out <- outer(1:4,1:4) out[lower.tri(out)] # [1] 2 3 4 6 8 12 来源: https://stackoverflow.com/questions/18899332/r-pairwise