Hello guys,
I have the same problem as mentionned. error: Subquery containing correlated aggregate function [MAX(INTER_ORDERED_PRODUCT.ORDERDATE)] can only appear in having or select clause
I have tried the solution that the community propose but still i encounter an error.
Context i’m using snowflake and dbt cloud.
best,
here what i did:
{{ config(schema=‘Marts’) }}
{{ config(materialized=“incremental”) }}
with mart_ordered_product as (
select * from {{ref (“inter_ordered_product”)}}
),
final as (
select
orderedkey,
partkey,
suppkey,
linenumber,
quantity,
extendedprice,
discount,
tax,
returnflag,
linestatus,
shipdate,
commitdate,
receitdate,
shipinstruct,
shipmode,
li_comment,
customer_key,
orderstatus,
totalprice,
orderdate,
orderpriority,
clerk,
shipriority,
o_comment
from mart_ordered_product
{%if is_incremental() %}
where mart_ordered_product.orderdate >= (select max(this.orderdate) from {{this}} as this)
{% endif%}
)
select * from final