user_id,profile,uname,win_lose,time 1,aho,baka,w,2006-03-14 19:00:00 1,roli,hiroyu(ry,w,2006-03-14 16:00:00 1,hoge,piyo,w,2006-03-12 11:00:00 のどれがほしいのよ 0110nobodyさんNGNG timeの最新のやつです。 0111nobodyさん2006/03/14(火) 20:25:15ID:??? 奈良、88でできるんじゃね? SELECT user_id, SUBSTRING(MAX(CONCAT(time,profile),9) AS profile, SUBSTRING(MAX(CONCAT(time,uname),9) AS uname, MAX(time) AS time, COUNT(*) AS cnt FROM users WHERE win_lose = 'w' GROUP BY user_id
どうも最新の結果が出てないっぽいのですね。 SELECT max(room_no) ,SUBSTRING( MAX( CONCAT(LPAD(room_no,10,'0'),profile) ), 11) AS profile, be_userid ,count(*) as winning , SUBSTRING( MAX( CONCAT(LPAD(room_no,10,'0'),uname) ), 11) AS uname FROM `user_entry` where `win_lose` = "w" group by be_userid order by winning DESC LIMIT 20;
SUBSTRING( MAX( CONCAT(LPAD(room_no,10,'0'),profile) ), 11) AS profile の部分のroom_noがMAXでないからかと思ったのですが、 エラーがでちゃうんですね。
SELECT max(room_no) ,SUBSTRING( MAX( CONCAT(LPAD(max(room_no),10,'0'),profile) ), 11) AS profile, be_userid ,count(*) as winning , SUBSTRING( MAX( CONCAT(LPAD(room_no,10,'0'),uname) ), 11) AS uname FROM `user_entry` where `win_lose` = "w" group by be_userid order by winning DESC LIMIT 20; ERROR 1111 (HY000): Invalid use of group function
テンポラリがいいか非効率でも関数ですませるかは元のテーブルの件数やインデックス なんかにもよると思うよ メモリーにでもテンポラリが作れればいいのかもしれないが 0122nobodyさん2006/03/15(水) 05:58:29ID:??? 文字列をゴリゴリ処理するなら、多少面倒でもPerlで組んだ方が楽なんだよなぁ・・・速いし・・・ 0123nobodyさん2006/03/15(水) 06:15:58ID:???>>117 ノシ select a.uname, a.handle_name, a.profile, a.be_userid, a.win_lose, count(a.win_lose) as w_kazu, max(b.room_no) as new_room from user_entry a inner join user_entry b on a.room_no = b.room_no group by b.be_userid having a.win_lose='w' order by w_kazu desc 0124参加者募集中!2006/03/15(水) 23:15:48ID:cWKpq76B 株式@2ch ★★★自動売買ソフトを作ろうぜ★★★ Part3 http://live19.2ch.net/test/read.cgi/stock/1141718486/l50 0125nobodyさん2006/03/15(水) 23:17:57ID:??? >124 金のないヒキに無縁の話です 0126nobodyさん2006/03/15(水) 23:19:50ID:cWKpq76B>>125 システム完成させてPC働かせて金持ちになろうぜ!