With two tables structured like this:
Table1 Table2
---------------- ----------------
id, time, x id, time, y, z
1 1 1 1 2 2 2
1 2 2 1 3 3 3
I am trying to join the tables to get a result that looks like this:
Result
--------------------------------
id, time, x, y, z
1 1 1
1 2 2 2 2
1 3 3 3
I was able to get a partial result with a query like this, but it is returning all of the values from table2 (including undesired ids) along with the joined values of table1.
select *
from Table1
full outer join Table2 on Table1.time=Table2.time and Table1.id ='1' and Table2.id ='1'
order by Table2.time
Does anyone know how to fix? I'm trying to run this query in AWS Athena/Prestodb if that matters.
Thanks for the help!
Best Answer
I don't use amazon-presto, but I'm wondering if you could adapt this SQL Server solution to your needs.