[datatable-help] Joins with or-condition
Wolfgang Steitz
wsteitz at gmail.com
Thu Jun 6 11:43:00 CEST 2013
Ok, here is a small example. I also changed the SQL a bit, I think
that it makes more sense this way.
SELECT sum(a.abc * b.abc)
FROM table_a as a
LEFT JOIN table_b as b
ON (a.y=b.y or a.y=b.z or a.z=b.y or a.z=b.z)
Group by a.xyz
table_a
id| y | z | abc | xyz
------------------------------
1 | l | u | 123.2 | a
2 | l | s | 13.5 | b
3 | s | u | 228.4 | f
4 | a | b | 427.2 | b
5 | a | a | 123.1 | a
6 | b | b | 180.2 | b
7 | c | c | 153.8 | f
8 | d | d | 113.2 | a
9 | d | a | 13.2 | f
table_b
id| y | z | abc
----------------
1 | l | u | 123.2
2 | l | s | 13.5
3 | s | u | 228.4
4 | a | b | 427.2
5 | a | a | 123.1
6 | b | b | 180.2
7 | c | c | 153.8
8 | d | d | 113.2
9 | d | a | 13.2
10| k | a | 123.1
11| k | b | 180.2
12| d | d | 153.8
13| c | d | 113.2
14| u | a | 13.2
On Thu, Jun 6, 2013 at 11:10 AM, statquant3 <statquant at outlook.com> wrote:
> Can you give us a data sample example (I know it's painful), but I do not
> know what ON really do. I have some experience with merges and could always
> avoir cartesian join...
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Joins-with-or-condition-tp4668801p4668804.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
More information about the datatable-help
mailing list