How to merge repeated values in table cells?

How can I prevent values from repeating in the 'From' and 'To' columns of my table? I want to display the data like this:

image

As you can see in the example above, instead of repeating 'XXXX' multiple times in the 'From' column, it appears only once. Same for 'YYYY' in the 'To' column. This creates a cleaner look where repeated values are merged into a single cell.

Currently, my table shows the same values repeated in every row. How can I achieve this merged cell effect?

Use a pivot table.

When i try to create a pivot table I get this

image

You'll need to do some sort of summary. Max or Min normally do the trick if there's just one record per cell.

What exactly do i need to do?

My table already has that because it's calculating an average. I tried throwing in a MAX in the final select and I get the same message.

My query for reference

with competitor as (
SELECT 
        DATE(timestamp) as date, 
        id_name as Competitor,
        source_chain as Source,
        destination_chain as Destination,
        asset as Token,
        transaction_amount as Amount,
        AVG(fee_amount) as AVG_FEE
    FROM `database.table_name`
WHERE {{Date}}
and {{From}}
and {{To}}
and {{Competitor}}
and {{Amount}}
and competitor != "COMPANY_A"
group by date, Competitor, Source, Destination, asset, transaction_amount
),
data AS (
    SELECT 
        DATE(timestamp) as date,
        'COMPANY_A' as Competitor,
        source_chain as Source,
        destination_chain as Destination,
        asset as Token,
        transaction_amount as Amount,
        AVG(fee_amount) as AVG_FEE
    FROM `database.table_name`
    WHERE {{Date}}
        AND {{From}}
        AND {{To}}
        AND {{Amount}}
        AND id_name = "COMPANY_A"
    GROUP BY date, Competitor, Source, Destination, Token, Amount
)
SELECT 
    c.*,
    r.AVG_FEE as COMPANY_A_FEE,
    (c.AVG_FEE - r.AVG_FEE) as FEE_DIFFERENCE,
    ROUND(((c.AVG_FEE - r.AVG_FEE) / r.AVG_FEE), 2) as PERCENTAGE_DIFFERENCE
FROM competitor c
LEFT JOIN data r 
    ON c.date = r.date 
    AND c.Source = r.Source 
    AND c.Destination = r.Destination 
    AND c.Token = r.Token 
    AND c.Amount = r.Amount;