mysql:15787
From: <gotou1213@xxxxxxxxxx>
Date: Wed, 11 Jul 2012 14:17:13 +0900
Subject: [mysql 15787] Re: カテゴリ毎の上位3件
後藤です。 以下のように相関サブクエリの回数を減らしたほうが早いかもしれません。 select a.category, a.name, a.price from ( select category, ( select price from saledata where category = g.category order by category asc, price asc limit 2,1 ) as price from ( select category from saledata group by category) g ) t inner join saledata a on a.category = t.category and a.price <= t.price ; 以上です。
15783 2012-07-11 02:56 [<shin-1@xxxxxxxxxx> ] カテゴリ毎の上位3件 15784 2012-07-11 10:27 ┣[高橋政利 <takahashi@] 15785 2012-07-11 12:28 ┣[中川 貴 <takashi.nak] 15796 2012-07-12 04:10 ┃┗[<shin-1@xxxxxxxxxx> ] 15786 2012-07-11 13:49 ┗[<gotou1213@xxxxxxxxx] -> 15787 2012-07-11 14:17 ┣[<gotou1213@xxxxxxxxx] 15788 2012-07-11 15:00 ┃┗[中川 貴 <takashi.nak] 15790 2012-07-11 16:09 ┗[<shin-1@xxxxxxxxxx> ] 15791 2012-07-11 17:11 ┣[あきら <akirainfoml@] 15794 2012-07-12 03:38 ┃┗[<shin-1@xxxxxxxxxx> ] 15792 2012-07-12 00:40 ┗[<gotou1213@xxxxxxxxx] 15795 2012-07-12 03:42 ┗[<shin-1@xxxxxxxxxx> ]