Join tables based on month values
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to join the tables by month to give 3 rows, one for each month.
The first row should be Jun-2018, Jun-2018. Second should be Jul-2018, Jul-2018. Last row should be Aug-2018, Aug 2018.
However, the original data is 1st June and 2nd June and it is causing the join to give me 6 rows.
a = table(datetime({'01-Jun-2018'; '01-Jul-2018'; '01-Aug-2018'}))
b = table(datetime({'02-Jun-2018'; '02-Jul-2018'; '02-Aug-2018'}))
a2 = table(datetime(a.Var1,"Format","MMM-uuuu"))
b2 = table(datetime(b.Var1,"Format","MMM-uuuu"))
outerjoin(a2,b2,'Keys','Var1')
Any solutions?
0 Kommentare
Antworten (1)
Prahlad Gowtham Katte
am 14 Feb. 2022
Hello,
As per my understanding of the query, you are trying to join two tables with similar month values using outer join. Your intended result can be achieved if you set MergeKeys to true in outer join function. If you replace the line which calls outer join function with the following it would resolve the problem.
outerjoin(a2,b2,"Keys","Var1","MergeKeys",true);
For more detailed explanation about the outer join function following link can be useful.
Hope it resolves your problem
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!