Car*_*son 5 database postgresql
我可以对hstore列中的值执行聚合查询吗?例如,我想确定商店SUM中的count字段.
Mik*_*ll' 14
是.但值存储为文本,因此您必须首先将它们转换为适当的数据类型.因此,以英寸为单位加总高度,这些高度存储在"其他"列中的hstore中
CREATE TABLE my_table (
id integer primary key,
other hstore
);
insert into my_table values
(1, hstore('height_in', '72') || hstore('weight_lbs', '180')),
(2, hstore('height_in', '65') || hstore('girth_in', '42'));
select sum((other->'height_in')::integer) sum_of_height
from my_table;
sum_of_height
--
137
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2470 次 |
| 最近记录: |