MySQLã§ãã£ããã¨ãããã¹ãã°ã©ã ãæ¸ã
MySQLã§ããã¹ãã°ã©ã çãªãã®ããµã¯ãã¨ä½ããã¨ãåºæ¥ããããããããªããã¡ãã¡CSVåãã¦Excelã«è²¼ãä»ãã¦ããã¿ãããªãã¨ã¾ã§ããªãã¦ãç°¡åã«ãã¼ã¿ã®åå¸ãè¦ããã
SELECT ROUND(numeric_value, -2) AS bucket, COUNT(*) AS COUNT, RPAD('', LN(COUNT(*)), '*') AS bar FROM my_table GROUP BY bucket;
ROUNDã§æ°å¤ã®ã«ã©ã ã®å¤ã丸ãã¦RPADã§ãã¼ãæç»ã
RPAD( æåå1, æåæ°, æåå2 )
ã¨ãã使ãæ¹ã§æ¬æ¥ã¯ç¬¬ä¸å¼æ°ã®æååã表示ããããã«ç¬¬ä¸å¼æ°ã§ããã£ã³ã°ãåããããã®é¢æ°ããããã©ããã®å ´å第ä¸å¼æ°ã空ã«ãã¦ä»»æã®æ°ã ããã¼ãæç»ããããã«ãã¦ãã¦è³¢ãã
ãã¼ã®é·ãã¯ã«ã¦ã³ãæ°ã®èªç¶å¯¾æ°ã§æ£è¦åãã¦ãã¦å²ãã¨ããã£ã½ãå¤ã«è¦ããã
+--------+----------+-----------------+ | bucket | count | bar | +--------+----------+-----------------+ | -500 | 1 | | | -400 | 2 | * | | -300 | 2 | * | | -200 | 9 | ** | | -100 | 52 | **** | | 0 | 5310766 | *************** | | 100 | 20779 | ********** | | 200 | 1865 | ******** | | 300 | 527 | ****** | | 400 | 170 | ***** | | 500 | 79 | **** | | 600 | 63 | **** | | 700 | 35 | **** | | 800 | 14 | *** | | 900 | 15 | *** | | 1000 | 6 | ** | | 1100 | 7 | ** | | 1200 | 8 | ** | | 1300 | 5 | ** | | 1400 | 2 | * | | 1500 | 4 | * | +--------+----------+-----------------+
å¼ç¨å : Rational Relational: How to Quickly Create a Histogram in MySQL