最大INET/CIDR考虑查询:如何查询分钟或者Postgres的
select min(d) from temp;
select max(d) from temp;
任一个,我得到一个错误,如:
# select max(d) from temp;
ERROR: function max(inet) does not exist
LINE 1: select max(d) from temp;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
所以,我创建一个表所谓的气温和填充它:
create table temp (d inet);
insert into temp (d) values ('1.1.10.2');
insert into temp (d) values ('1.1.10.10');
insert into temp (d) values ('1.1.10.20');
insert into temp (d) values ('1.1.10.100');
# select * from temp order by d;
d
------------
1.1.10.2
1.1.10.10
1.1.10.20
1.1.10.100
(4 rows)
所以,我可以使用主机()转换为文本,而是产生不正确的答案:
select min(host(d)) from temp;
那是因为它是做一个文本“分钟”功能,这是这个顺序:
# select host(d) as r from temp order by r;
r
------------
1.1.10.10
1.1.10.100
1.1.10.2
1.1.10.20
(4 rows)
是否有在Postgres的IP类型一分钟()和MAX()函数?有办法来欺骗它(转换为int并进行比较,或者通过限制进行排序)。我对适当的min()和max()更感兴趣。谢谢你这么!
-g
我读到这http://www.postgresql.org/message-id/[email protected]om和我认为已经有一个补丁修复了这个问题。但我尝试了PG9.3它失败了,我的朋友试图在9.4它失败too.i认为你可以做的是映射到int和使用min()在那 –