Afonso_Diaz2023-08-30 12:24 AM
    Updated 2023-08-30
    with

    t0 as (
    select distinct tx_id from sei.core.fact_msg_attributes
    where attribute_key = '_contract_address'
    and attribute_value = 'sei1d2r4s2q8kumpmvx6dyj77klhgm5e6fs9njmmz6ye7ukqa77ddtdsu72dc3'
    ),

    t as (
    select * from sei.core.fact_msg_attributes a
    where attribute_key in ('offer_asset', 'ask_asset', 'offer_amount', 'return_amount')
    and tx_id in (select tx_id from t0)
    ),

    t3 as (
    select * from t c
    where not attribute_value in (
    (
    select a.attribute_value
    from t a
    join t b
    using(tx_id)
    where a.attribute_key = 'offer_amount'
    and b.attribute_key = 'return_amount'
    and a.attribute_value = b.attribute_value
    and c.tx_id = a.tx_id
    )
    )
    and not attribute_value in (
    (
    select a.attribute_value
    from t a
    join t b
    using(tx_id)
    where a.attribute_key = 'ask_asset'
    and b.attribute_key = 'offer_asset'
    Run a query to Download Data