BIGINT UNSIGNED value is out of range in '(`nodeny`.`a`.`last` - `nodeny`.`a`.`start`)'
{
'param' => [
'ufio',
'ФИО',
0,
'uname',
'Логин',
1,
'ucontract',
'Договор',
2,
'ucomment',
'Комментарий',
3,
'uid',
'Id',
4,
'ubalance',
'Баланс',
5,
'utraf',
'Трафик, Мб',
6,
'utraf_out',
'Исх. трафик, Мб',
7,
'utraf_in',
'Вх. трафик, Мб',
8,
'utraf1',
'Трафик 1 направления, Мб',
9,
'utraf4',
'Трафик 4 направления, Мб',
10,
'ustate',
'Заблокирован',
11,
'ulstate',
'Всегда онлайн',
12,
'ucstate',
'Состояние',
13,
'ucontract_date',
'Дата договора',
14,
'ulimit_balance',
'Граница отключения',
15,
'ublock_if_limit',
'Отключать ли по балансу',
16,
'udiscount',
'Скидка, %',
17,
'iip',
'ip',
18,
'iauth',
'Авторизация',
19,
'itm_auth',
'Длит. авторизации, сек',
20,
'iproperties',
'Параметры авторизации',
21,
'd_mac',
'mac',
22,
'd_serv_street',
'улица обслуживания',
23,
'd_serv_house',
'дома обслуживания',
24,
'd_serv_front_door',
'подьезд обслуживания',
25,
'd_adr_place',
'Точка топологии',
26,
'd_ip_tag',
'IP Pool',
27,
'd_adr_street',
'Улица',
28,
'd_adr_house',
'Дом',
29,
'd_adr_front_door',
'Подъезд',
30,
'd_adr_room',
'Квартира',
31,
'd_adr_telefon',
'Телефон',
32,
'd_maconu',
'MAC S/N ONU',
33,
'd_email',
'E-mail',
34,
'd_smtp',
'smtp port 25',
35,
'd_telegram_id',
'Телеграм id',
36,
'd_snmp',
'snmp конфиг',
37
],
'sql' => 'SELECT * FROM (
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.fio LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.name LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.contract LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.comment LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.id LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.balance LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.traf LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.traf_out LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.traf_in LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.traf1 LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.traf4 LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.state LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.lstate LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.cstate LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.contract_date LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.limit_balance LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.block_if_limit LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM fullusers u WHERE u.discount LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.ip LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.auth LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.tm_auth LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.properties LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._mac LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, \'~\', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE \'10.0.15%\' AND type=\'street\') dict JOIN data0 d ON dict.k=d._serv_street JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._serv_house LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._serv_front_door LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, \'~\', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE \'10.0.15%\' AND type=\'place\') dict JOIN data0 d ON dict.k=d._adr_place JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, \'~\', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE \'10.0.15%\' AND type=\'ip_tags\') dict JOIN data0 d ON dict.k=d._ip_tag JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, \'~\', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE \'10.0.15%\' AND type=\'street\') dict JOIN data0 d ON dict.k=d._adr_street JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_house LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_front_door LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_room LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_telefon LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._maconu LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._email LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._smtp LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, \'10.0.15\' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._telegram_id LIKE \'10.0.15%\' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT ? AS alias, ? AS title, ? AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, \'~\', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE \'10.0.15%\' AND type=\'snmp\') dict JOIN data0 d ON dict.k=d._snmp JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0
) AS a WHERE a.grp IN(25,14,20,18,62,63,49) ORDER BY a.grp, CAST(a.`order` AS UNSIGNED)'
};
SELECT * FROM (
SELECT 'ufio' AS alias, 'ФИО' AS title, '0' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.fio LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'uname' AS alias, 'Логин' AS title, '1' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.name LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ucontract' AS alias, 'Договор' AS title, '2' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.contract LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ucomment' AS alias, 'Комментарий' AS title, '3' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.comment LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'uid' AS alias, 'Id' AS title, '4' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.id LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ubalance' AS alias, 'Баланс' AS title, '5' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.balance LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'utraf' AS alias, 'Трафик, Мб' AS title, '6' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.traf LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'utraf_out' AS alias, 'Исх. трафик, Мб' AS title, '7' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.traf_out LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'utraf_in' AS alias, 'Вх. трафик, Мб' AS title, '8' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.traf_in LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'utraf1' AS alias, 'Трафик 1 направления, Мб' AS title, '9' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.traf1 LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'utraf4' AS alias, 'Трафик 4 направления, Мб' AS title, '10' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.traf4 LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ustate' AS alias, 'Заблокирован' AS title, '11' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.state LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ulstate' AS alias, 'Всегда онлайн' AS title, '12' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.lstate LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ucstate' AS alias, 'Состояние' AS title, '13' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.cstate LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ucontract_date' AS alias, 'Дата договора' AS title, '14' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.contract_date LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ulimit_balance' AS alias, 'Граница отключения' AS title, '15' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.limit_balance LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'ublock_if_limit' AS alias, 'Отключать ли по балансу' AS title, '16' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.block_if_limit LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'udiscount' AS alias, 'Скидка, %' AS title, '17' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM fullusers u WHERE u.discount LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'iip' AS alias, 'ip' AS title, '18' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.ip LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'iauth' AS alias, 'Авторизация' AS title, '19' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.auth LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'itm_auth' AS alias, 'Длит. авторизации, сек' AS title, '20' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.tm_auth LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'iproperties' AS alias, 'Параметры авторизации' AS title, '21' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM v_ips i JOIN users u ON i.uid=u.id WHERE i.properties LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_mac' AS alias, 'mac' AS title, '22' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._mac LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_serv_street' AS alias, 'улица обслуживания' AS title, '23' AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, '~', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE '10.0.15%' AND type='street') dict JOIN data0 d ON dict.k=d._serv_street JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT 'd_serv_house' AS alias, 'дома обслуживания' AS title, '24' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._serv_house LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_serv_front_door' AS alias, 'подьезд обслуживания' AS title, '25' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._serv_front_door LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_adr_place' AS alias, 'Точка топологии' AS title, '26' AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, '~', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE '10.0.15%' AND type='place') dict JOIN data0 d ON dict.k=d._adr_place JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT 'd_ip_tag' AS alias, 'IP Pool' AS title, '27' AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, '~', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE '10.0.15%' AND type='ip_tags') dict JOIN data0 d ON dict.k=d._ip_tag JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT 'd_adr_street' AS alias, 'Улица' AS title, '28' AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, '~', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE '10.0.15%' AND type='street') dict JOIN data0 d ON dict.k=d._adr_street JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0 UNION ALL
SELECT 'd_adr_house' AS alias, 'Дом' AS title, '29' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_house LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_adr_front_door' AS alias, 'Подъезд' AS title, '30' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_front_door LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_adr_room' AS alias, 'Квартира' AS title, '31' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_room LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_adr_telefon' AS alias, 'Телефон' AS title, '32' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._adr_telefon LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_maconu' AS alias, 'MAC S/N ONU' AS title, '33' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._maconu LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_email' AS alias, 'E-mail' AS title, '34' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._email LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_smtp' AS alias, 'smtp port 25' AS title, '35' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._smtp LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_telegram_id' AS alias, 'Телеграм id' AS title, '36' AS `order`, u.grp, COUNT(*) AS n, '10.0.15' AS value FROM data0 d JOIN users u ON d.uid=u.id WHERE d._telegram_id LIKE '10.0.15%' GROUP BY u.grp HAVING COUNT(*)>0 UNION ALL
SELECT 'd_snmp' AS alias, 'snmp конфиг' AS title, '37' AS `order`, u.grp, COUNT(*) AS n, CONCAT(dict.k, '~', dict.v) AS value FROM (SELECT k, v FROM dictionary WHERE v LIKE '10.0.15%' AND type='snmp') dict JOIN data0 d ON dict.k=d._snmp JOIN users u ON d.uid=u.id GROUP BY u.grp, dict.k HAVING COUNT(*)>0
) AS a WHERE a.grp IN(25,14,20,18,62,63,49) ORDER BY a.grp, CAST(a.`order` AS UNSIGNED)