-------------- SELECT iden, age FROM elf WHERE sexe=1 ORDER BY iden LIMIT 3 -------------- +------+-----+ | iden | age | +------+-----+ | M001 | 62 | | M003 | 31 | | M004 | 27 | +------+-----+ 3 rows in set (0.00 sec) -------------- SELECT etud, ROUND(100*COUNT(iden)/99) FROM elf GROUP BY etud -------------- +------+---------------------------+ | etud | ROUND(100*COUNT(iden)/99) | +------+---------------------------+ | 0 | 3 | | 1 | 6 | | 2 | 30 | | 3 | 21 | | 4 | 39 | +------+---------------------------+ 5 rows in set (0.00 sec) -------------- SELECT etud, AVG(age) FROM elf GROUP BY etud -------------- +------+----------+ | etud | AVG(age) | +------+----------+ | 0 | 50.0000 | | 1 | 56.8333 | | 2 | 35.6000 | | 3 | 35.2381 | | 4 | 32.0000 | +------+----------+ 5 rows in set (0.00 sec) -------------- SELECT elfetud.label, ROUND(COUNT(elf.etud)*100/99) AS eff, "%" FROM elf, elfetud WHERE elfetud.code=elf.etud GROUP BY etud ORDER BY eff DESC -------------- +-------------------+------+---+ | label | eff | % | +-------------------+------+---+ | supérieur | 39 | % | | secondaire (bepc) | 30 | % | | baccalauréat | 21 | % | | primaire | 6 | % | | non-réponse | 3 | % | +-------------------+------+---+ 5 rows in set (0.00 sec) -------------- SELECT etud, AVG(age) AS moya FROM elf GROUP BY etud ORDER BY moya DESC -------------- +------+---------+ | etud | moya | +------+---------+ | 1 | 56.8333 | | 0 | 50.0000 | | 2 | 35.6000 | | 3 | 35.2381 | | 4 | 32.0000 | +------+---------+ 5 rows in set (0.00 sec) -------------- SELECT etud, AVG(age) AS moya FROM elf GROUP BY etud HAVING moya > 45 ORDER BY moya DESC -------------- +------+---------+ | etud | moya | +------+---------+ | 1 | 56.8333 | | 0 | 50.0000 | +------+---------+ 2 rows in set (0.00 sec) -------------- SELECT etud, AVG(age) as moya FROM elf WHERE sexe=1 GROUP BY etud HAVING moya > 45 ORDER BY moya DESC -------------- +------+---------+ | etud | moya | +------+---------+ | 0 | 63.0000 | | 1 | 59.6000 | +------+---------+ 2 rows in set (0.00 sec) -------------- select etud, AVG(age) as moya from elf where sexe=1 group by etud having moya > 45 order by moya desc limit 10 -------------- +------+---------+ | etud | moya | +------+---------+ | 0 | 63.0000 | | 1 | 59.6000 | +------+---------+ 2 rows in set (0.00 sec) -------------- SELECT COUNT(sexe) FROM tmpElf WHERE sexe=1 -------------- +-------------+ | COUNT(sexe) | +-------------+ | 33 | +-------------+ 1 row in set (0.00 sec) -------------- SELECT " SURTOUT PAS " AS incorrect , COUNT(*) FROM elf WHERE sexe=1 LIMIT 50 -------------- +---------------+----------+ | incorrect | COUNT(*) | +---------------+----------+ | SURTOUT PAS | 64 | +---------------+----------+ 1 row in set (0.00 sec) -------------- SELECT COUNT(*) FROM (SELECT * FROM elf ORDER BY iden LIMIT 50 ) AS tmp WHERE sexe=1 ; -------------- +----------+ | COUNT(*) | +----------+ | 33 | +----------+ 1 row in set (0,00 sec) Bye