RODBの取引履歴が6/21 9:59以降記録されてないっぽくてちと残念. 各インペ服の平均価格
SELECT item_name AS 'アイテム名' ,
SUM(cost) / SUM(count) AS '平均価格',
SUM(count) AS '件数'
FROM item_detail_tbl
WHERE (item_name LIKE 'インペリアル%ローブ%' OR
item_name LIKE 'インペリアル%スーツ%' ) AND
datetime < (NOW() - INTERVAL 3 MONTH) AND
smelting LIKE 0
GROUP BY item_name
ORDER BY 2 DESC,1;