var sql = mysql.format('select count(1) as count,\'t1\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline > ?) t1 where t1.type=\'cmic01\' union select count(1) as count,\'t2\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline > ?) t1 where t1.type=\'cmic02\' union select count(1) as count,\'t3\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline > ?) t1 where t1.type=\'cmic03\' union select count(1) as count,\'t3\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline > ?) t1 where t1.type=\'cmic04\' ', [getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 43200, getTimestamp() - 86400]);
sql += mysql.format(' union select count(1) as count,\'t4\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ? and lastonline > ?) t1 where t1.type=\'cmic01\' union select count(1) as count,\'t5\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ? and lastonline > ?) t1 where t1.type=\'cmic02\' union select count(1) as count,\'t6\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ? and lastonline > ?) t1 where t1.type=\'cmic03\' union select count(1) as count,\'t6\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ? and lastonline > ?) t1 where t1.type=\'cmic04\' ', [getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 86400 * 7, getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 86400 * 7, getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 86400 * 7, getTimestamp() - 43200, getTimestamp() - 86400, getTimestamp() - 86400 * 7]);
sql += mysql.format(' union select count(1) as count,\'t7\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ?) t1 where t1.type=\'cmic01\' union select count(1) as count,\'t8\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ?) t1 where t1.type=\'cmic02\' union select count(1) as count,\'t9\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ?) t1 where t1.type=\'cmic03\' union select count(1) as count,\'t9\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and lastonline < ?) t1 where t1.type=\'cmic04\'', [getTimestamp() - 43200, getTimestamp() - 86400 * 7, getTimestamp() - 43200, getTimestamp() - 86400 * 7, getTimestamp() - 43200, getTimestamp() - 86400 * 7, getTimestamp() - 43200, getTimestamp() - 86400 * 7]);
sql += mysql.format(' union select count(1) as count,\'t10\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and updatedat < ?) t1 where t1.type=\'cmic01\' union select count(1) as count,\'t11\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and updatedat < ?) t1 where t1.type=\'cmic02\' union select count(1) as count,\'t12\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and updatedat < ?) t1 where t1.type=\'cmic03\' union select count(1) as count,\'t12\' from (select substr(did,1,6) as type from mysql.mm_statusccc where updatedat > ? and updatedat < ?) t1 where t1.type=\'cmic04\'', [getTimestamp() - 86400, getTimestamp() - 3600, getTimestamp() - 86400, getTimestamp() - 3600, getTimestamp() - 86400, getTimestamp() - 3600, getTimestamp() - 86400, getTimestamp() - 3600]);