次のようなmysqlテーブルがあります。
mysql> select * from pt_onhand where pn = '000A569011';
+------------+-----+----+--------+------------+---------+--------------+-----+
| pn | pa | mn | ACTIVE | locate | onhand | avg_cost | whs |
+------------+-----+----+--------+------------+---------+--------------+-----+
| 000A569011 | P/A | | | AA-112 | 13.0000 | 0.0000000000| |
| 000A569011 | P/A | | | PF120136.1 | 1.0000 | 5.4785156200 | |
+------------+-----+----+--------+------------+---------+--------------+-----+
そして、次のようなクエリを実行したい:
mysql> select sum(onhand),max(locate),avg_cost from pt_onhand where pn = '000A569011' group by pn;
+-------------+-------------+--------------+
| sum(onhand) | max(locate) | avg_cost |
+-------------+-------------+--------------+
| 14.0000 | PF120136.1 | 0.0000000000|
+-------------+-------------+--------------+
私の質問は次のとおりです。同じクエリで max(locate) PF120136.1 に関連する avg_cost 5.4785156200 を取得できますか? ありがとう