Table One:
Table Two:
Inner Joined Table (One+Two)
Hi SQL Experts,
I am quite new to complex SQL queries and am facing some difficulties with Inner Join query returning duplicated records.
This is the SQL query:
DEFINE TABLE new_table (
QUERY =
"""
SELECT
customer_name as B,
day as A,
value as E,
""",
);
CREATE OR REPLACE TABLE Inner_Joined_Table as
SELECT
A,
B,
C,
D,
E,
FROM new_table a
inner join (select A, B, D, from Table_Two group by A, B, D) b
on a.B = b.B AND a.A = b.A
inner join (select A, B, E, from Table_One group by A, B, E) c
on a.B = b.B AND a.A = c.A
GROUP BY A, B, C, D, E;
SELECT * from Inner_Joined_Table
Expected: Should be able to SUM up column E into single day and single user and not create duplicated records but I am stuck.
Thanks!