带窗口的多重计数(子字符串) psql 8.4.4
我正在尝试创建以下视图,但出现以下错误: 我可以执行 1 个计数语句(如果删除 AS“Mod0”)是否可以对多个子字符串进行计数,并将输出计数到新列?
create view portcnt as
select
address,
datacenter,
ifdesc,
count(substring(ifdesc, 'Ethernet0/*')) as "Mod0",
count(substring(ifdesc, 'Ethernet1/*')) as "Mod1",
count(substring(ifdesc, 'Ethernet2/*')) as "Mod2",
count(substring(ifdesc, 'Ethernet3/*')) as "Mod3",
count(substring(ifdesc, 'Ethernet4/*')) as "Mod4",
count(substring(ifdesc, 'Ethernet5/*')) as "Mod5",
count(substring(ifdesc, 'Ethernet6/*')) as "Mod6"
over (partition by address)
from ifstatus where datacenter = 'DC'
and ifadminstatus = '1' and ifoperstatus = '1';
ERROR: syntax error at or near "by"
LINE 13: over (partition by address)
I am trying to create the following view, and I get the error below:
I am able to do 1 count statement (if I remove the AS "Mod0") Is it possible to count multiple substrings, with the output count to a new column?
create view portcnt as
select
address,
datacenter,
ifdesc,
count(substring(ifdesc, 'Ethernet0/*')) as "Mod0",
count(substring(ifdesc, 'Ethernet1/*')) as "Mod1",
count(substring(ifdesc, 'Ethernet2/*')) as "Mod2",
count(substring(ifdesc, 'Ethernet3/*')) as "Mod3",
count(substring(ifdesc, 'Ethernet4/*')) as "Mod4",
count(substring(ifdesc, 'Ethernet5/*')) as "Mod5",
count(substring(ifdesc, 'Ethernet6/*')) as "Mod6"
over (partition by address)
from ifstatus where datacenter = 'DC'
and ifadminstatus = '1' and ifoperstatus = '1';
ERROR: syntax error at or near "by"
LINE 13: over (partition by address)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一个有效的解决方案:
found a solution that worked: