HAVING MIN( wp_postmeta.meta_value )
SELECT Category, AVG(Price) AS AvgPrice
FROM SomeTable
WHERE Price > 0
GROUP BY Category
HAVING AvgPrice < 10 AND COUNT(Price) > 2
SELECT MinPricesQuery.MinPrice
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN (запрос_возвращающий_минимальные_цены) MinPricesQuery ON (wp_posts.ID = MinPricesQuery.Id)
WHERE
wp_term_relationships.term_taxonomy_id IN (%d)
AND wp_posts.post_type = 'product'
wp_term_relationships.term_taxonomy_id IN (%d)
wp_term_relationships.term_taxonomy_id = %d
id IN (10,20,30)
id IN (SELECT Value FROM SomeTable)
https://habr.com/ru/post/164973/
Ну и само собой дока MS
https://docs.microsoft.com/uk-ua/visualstudio/exte...