queries

Wildcard

  • select name from table1 where name rlike ’^1[0-9].KA’

Group by monthly

  • SELECT MONTH(datetime_column) , COUNT(row) FROM table WHERE datetime_column >= NOW() – INTERVAL 1 YEAR GROUP BY MONTH(datetime_column);

Count specific days

  • select count(*) from table_name where datetime_column > ”2015-08-01” AND datetime_column < ”2015-08-31”;

Group by daily (specific days)

  • SELECT COUNT(*), DATE(datetime_column) FROM table WHERE DATE(datetime_column) >= DATE(’2015-08-01’) AND DATE(datetime_column) <= DATE(’2015-08-25’) GROUP BY DATE(datetime_column);

Count unique conditions

  • SELECT nimi, COUNT(*) FROM table_name GROUP BY nimi HAVING COUNT(*) > 1