anonīms Posted April 30, 2010 Report Share Posted April 30, 2010 tabula km1, km2, km1_rez, km2_rez Nepieciešams iegūt top 5 komandām pēc iesistajiem. Izvadu ar while top 5 komandas. Ideja ir tāda, bet nezinu kā to dabūt gatavu jau iekšs kverija. $Q = "(SELECT sum(km1_rez)FROM speles WHERE km1 = ?) AS goli1, (SELECT sum(km2_rez) AS goli1 FROM speles WHERE km2 = ?) AS goli2"; // order by goli1+goli2 DESC while($qq = fetch_assoc($Q) { } Vajag iekšs (?) - jautājumzīmēm dabūt ID. Ceru, ka ideja tapa skaidra. Iepildīta tabula izsaktās apmēram šādi km1, km2, km1_rez, km2_rez1, 6, 14, 2 3, 1 5, 4 Quote Link to comment Share on other sites More sharing options...
php newbie Posted April 30, 2010 Report Share Posted April 30, 2010 es kko tādu uz ātro roku samurgoju :D sintakse nav pareiza, bet ceru ka ideja ir skaidra SELECT komanda, SUM(rez) as rezultats FROM (SELECT SUM(km1_rez) as rez, km1 as komanda FROM SPELES GROUP BY km1 UNION SELECT SUM(km2_rez) as rez, km2 as komanda FROM SPELES GROUP BY km2) as sr GROUP BY komanda ORDER BY rez DESC Quote Link to comment Share on other sites More sharing options...
anonīms Posted May 1, 2010 Author Report Share Posted May 1, 2010 iet kā smērēts: http://paste.php.lv/86b2b1f5be40f5fe02844723dbc161a5/nonum Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.