Новости
Документация
Download
Webboard
Поиск
FAQ/ЧаВо
Обратная связь




MySQL.RU - Webboard



Вернуться
concat + group by (swop) 14/05/2004 - 18:15:51



From: swop - 14/05/2004 - 18:15:51
Subject:concat + group by
-----------------
Всем доброго дня.

есть таблица

`unix_secs` int(11) unsigned default NULL,
`unix_nsecs` int(11) unsigned default NULL,
`sysuptime` int(11) unsigned default NULL,
`router_id` smallint(1) unsigned default NULL,
`dpkts` tinyint(4) unsigned default NULL,
`doctets` tinyint(4) unsigned default NULL,
`first` int(11) unsigned default NULL,
`last` int(11) unsigned default NULL,
`src_oct_0` tinyint(1) unsigned default NULL,
`src_oct_1` tinyint(1) unsigned default NULL,
`src_oct_2` tinyint(1) unsigned default NULL,
`src_oct_3` tinyint(1) unsigned default NULL,
`dst_oct_0` tinyint(1) unsigned default NULL,
`dst_oct_1` tinyint(1) unsigned default NULL,
`dst_oct_2` tinyint(1) unsigned default NULL,
`dst_oct_3` tinyint(1) unsigned default NULL,
`id_if-in-index` tinyint(1) unsigned default NULL,
`id_if-ou-index` tinyint(1) unsigned default NULL,
`src_port` tinyint(2) unsigned default NULL,
`dst_port` tinyint(2) unsigned default NULL,
`proto_id` tinyint(2) unsigned default NULL


делаю над ней выборку

select concat(dst_oct_0, '.', dst_oct_1, '.', dst_oct_2, '.', dst_oct_3) as dest, sum(doctets)
from accounting
group by dst_oct_0, dst_oct_1, dst_oct_2, dst_oct_3
limit 10;


получаю сей бред

+---------+--------------+
| dest | sum(doctets) |
+---------+--------------+
| 4.4.73. | 255 |
| 4.4.141 | 255 |
| 4.4.237 | 255 |
| 4.8.13. | 747 |
| 4.8.73. | 255 |
| 4.8.253 | 255 |
| 4.10.22 | 275 |
| 4.11.51 | 335 |
| 4.14.12 | 255 |
| 4.14.16 | 570 |
+---------+--------------+


должно быть 4 октета! вся эта фигня происходит при групировке, как быть ? :(

версия mysql = 3.23. также проверялось на 4.0.15 standart.

для сравнения приведу тотже запрос но на MSSQL

select top 10 cast (dst_oct_0 as varchar(3)) + '.' +
cast (dst_oct_1 as varchar(3)) + '.' +
cast (dst_oct_2 as varchar(3)) + '.' +
cast (dst_oct_3 as varchar(3)) as dest,
sum (doctets) / 1024 as kbyte
from accounting
group by dst_oct_0, dst_oct_1, dst_oct_2, dst_oct_3
order by kbyte desc


195.68.129.93 46142
172.20.0.13 15845
172.20.7.255 5484
213.33.223.162 5395
10.10.11.128 2717
172.20.0.11 2050
172.20.3.100 1505
172.20.0.178 1375
10.10.1.176 1284
194.67.23.20 1276



[Это сообщение - спам!]

Последние сообщения из форума

Уважаемые посетители форума MySQL.RU!
Убедительная просьба, прежде чем задавать свой вопрос в этом форуме, обратите внимание на разделы:
- ответы на наиболее часто задаваемые вопросы - FAQ
- раздел документация
- раздел поиск по сообщениям форума и документации
Также, старайтесь наиболее подробно указывать свою ситуацию (версию операционной системы, версию MySQL, версию программного обеспечения, по которому возникает вопрос, текст возникающих ошибок, и др.)
Помните, чем конкретнее Вы опишете ситуацию, тем больше шансов получить реальную помощь.
 Имя:
 E-mail:
 Тема:
 Текст:
Код подтверждения отправки: Code
14739



РЕКЛАМА НА САЙТЕ
  Создание сайтов | |