I believe I found a bug in your system.
At the end of the query I have a conditional statement to check the value of the control manufacturer.value
The issue is even if the control has a value the results ignore it in retool
Here is the query
select distinct
o.increment_id as Order_ID,
o.created_at as Order_Date,
w.reseller_id as Member,
w.company_name as Vend_Name,
z.city,
z.region,
eaov.value as MFG,
b.sup_name as Distributor,
s.company_supplier_code as Dist_Acct_num,
i.sku AS pop_sku,
n.value AS Product_Description,
sw.value as Size,
get_deal_name(get_deal_id(product_options
)) AS program,
v.qty AS pop_qty,
v.Ship_Date AS Ship_Date,
i.am_earn_reward_points As Rebate
FROM sales_order o
JOIN sales_order_item i ON i.order_id = o.entity_id
JOIN products_vertical v ON i.item_id = v.item_id
JOIN catalog_product_entity_varchar n ON n.entity_id = i.product_id AND n.attribute_id = 73
LEFT JOIN catalog_product_entity_varchar sw ON sw.entity_id = i.product_id AND sw.attribute_id = 154
LEFT JOIN catalog_product_entity_int ma ON ma.entity_id = i.product_id AND ma.attribute_id = 83
LEFT JOIN eav_attribute_option eao ON ma.value = eao.option_id
LEFT JOIN eav_attribute_option_value eaov ON eao.option_id = eaov.option_id
left join technopath_company_address_supplier s on s.customer_id = o.customer_id and s.supplier_id = v.supplier_id and s.shipping_address_id = v.location_id
left join bms_supplier b on b.sup_id = s.supplier_id
left join amasty_company_account_company w on w.company_id = s.company_id
left join sales_order_address z on z.entity_id = v.Location_id
left join catalog_product_link l on l.linked_product_id = i.product_id and l.link_type_id = 3
where
o.created_at between {{dateRange1.value.start}} and {{dateRange1.value.end}}
{{ manufacturer.value ? AND eao.option_id IN (${manufacturer.value})
: '' }}
**Here is the debug from running the query, it returns all results ignoring the value in the IN statement
see the results returned by retool and notice how the mfg column has all MFGs where it should only have General mills which is = 16
When i take the query generated in the debug and run 'as is' in mysql workbench i get 139 results, only General Mills
**When i change the code in retool query without the if condition in the where I get just general mills. Notice how the query is the same in the debug