i have some problem in BigQuery,
i have 2 tables first tables is paymentdate
| Customer_id | paid_date |
|---|---|
| aaa | 2021/01/23 |
| aaa | 2021/01/24 |
| bbb | 2020/01/12 |
second table is amount_table
| Costemer_id | date | conceptID | amount |
|---|---|---|---|
| aaa | 2021/01/23 | principal | 1000 |
| aaa | 2021/01/23 | interest | 200 |
| aaa | 2021/01/24 | late_fee | 30 |
| aaa | 2021/01/24 | principal | 1000 |
| bbb | 2020/01/12 | principal | 250 |
and i want to write query using STRUCT and the result that i want is :
| customer_id | paid_date | concept_id | amount |
|---|---|---|---|
| aaa | 2021/01/23 | principal | 100000 |
| interest | 200 | ||
| aaa | 2021/01/24 | late_fee | 30 |
| principal | 10000 | ||
| bbb | 2020/01/12 | principal | 250 |
i already write query but it doesnt work
select
paymentdate.customer_id,paymentdate.paid_date , array(select struct(concept_id,amount) fromamount_tablewhereamount_table.customer_id=paymentdate.customer_id andamount_table.paid_date=paymentdate.paid_date) frompaymentdate
anyone can help ?