I'm still confused about joining two tables.
I have two tables: Raw_Data and Totals. I need to join them but I'm getting the wrong result.
Here is my raw data table:
Username Parents | Boy
WIL111 | Abc | ABC_VIVO
WIL111 | Abc | ALT_KATONG
WIL111 | ALT | ALT_KATONG
Here is my total table:
Username | Father | Child | Total
WIL111 | Abc | ABC_VIVO | fifteen
WIL111 | Abc | ALT_KATONG | fifteen
WIL111 | ALT | ALT_KATONG | 8
select FUsername, FChild_WP, AA_WC_TOTALS.TOTTotalSum_Parent,
from dbo.RAW_DATA
JOIN dbo.TOTALS in RAW_DATA.FUsername = Totals.Username AND
RAW_DATA.FChild_WP = Totals.Child AND
RAW_DATA.Parent = Totals.Child
ORDER BY Username, Child;
This exit is showing me:
Father | Username | Child | Sum
Abc | WIL111 | ABC_VIVO | fifteen
ALT | WIL111 | ALT_KATONG | fifteen
ALT | WIL111 | ALT_KATONG | 8
If you see it, it should be double ABC, do not double ALT. Please help. I try to modify the conditions but I can not get the correct data.
I'm waiting for an exit like:
Father | Username | Child | Sum
Abc | WIL111 | ABC_VIVO | fifteen
Abc | WIL111 | ALT_KATONG | fifteen
ALT | WIL111 | ALT_KATONG | 8
Thank you!