对 T-SQL 中 2 列的最大值进行子查询的最佳方法是什么

What is the best way to do a sub query for a max on 2 columns in T-SQL

我有三个table。

出于交付目的,我希望 return Product_heightProduct_length 的最大值可以来自产品 table.

中的多个产品

所以我希望输出看起来像这样:

Sales_Ordernum,
Customer,
Max_Productheight,
Max_Productlength

感谢任何帮助

谢谢

您可以加​​入和聚合:

select sh.sales_ordernum, sh.customer, 
    max(p.product_height) as max_product_height,
    max(p.product_length) as max_product_length
from sales_header sh
inner join sales_details sd on sd.sales_ordernum = sh.sales_ordernum
inner join product p on p.product_number = sd.product_number
group by sh.sales_ordernum, sh.customer