ERROR: type "sum" does not exist
开发问pg中执行一个简单的语句,多次报错:
> ERROR: type "sum" does not exist
LINE 1: SELECT SUM
^
看看具体的语句,其实是个很简单的语句,怎么会报类型sum不存在呢?
SELECT SUM
(es.money_stock ) 'sum_money',
es.material_no,
es.price
FROM
es
GROUP BY
es.material_no,
es.price;
其实这是的问题在于select语句中列的别名的写法规范问题。以下是pg文档中的描述:

在SQL标准中,只要新列名是有效的列名(即与任何保留关键字不同),就可以在输出列名之前省略可选关键字AS。
PostgreSQL的限制更严格:如果新的列名完全匹配任何关键字,则保留AS,无论是否是保留字。
推荐的做法是使用AS或双引号输出列名,以防止与将来添加关键字的任何可能的冲突。
在FROM项中,标准sql和PostgreSQL都允许省略AS之前的AS,如果该别名不是保留的关键字。但是由于语法上的歧义,这对于输出列名称是不切实际的。
所以这里真正的问题是单引号的使用。去掉单引号即可。 当然也可以将单引号换成双引号。
ERROR: type "sum" does not exist的更多相关文章
- react-native run-android Starting: Intent Error type 3 Error: Activity class does not exist
使用”react-native run-android”命令运行android应用时,如果常常出现如下错误: Starting the app (/home/xxx/soft/sdk//platfor ...
- [转载]Vertica “ERROR: Too many ROS containers exist”
最近在用Vertica的时候碰到一个问题,Vertica在运行了一段时间后总是出现类似下面的错误 1: java.sql.SQLException: [Vertica][VJDBC](5065) 2: ...
- windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help
windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help 在windows8操作系统上安装 ...
- PostgreSql问题:ERROR: column "1" does not exist
摘录自:http://blog.csdn.net/shuaiwang/article/details/1807421 在PostgreSQL中,不论是在pgAdmin中还是在命令行控制台里面,在SQL ...
- ssh 报error: kex protocol error: type 30 seq 1
由于近期服务器升级了openssl,在使用navicat连接数据库报 查看日志 sshd[1990]: error: kex protocol error: type 30 seq 1 [preaut ...
- pgsql 执行建库脚本时候出现ERROR: relation "xxx_id_seq" does not exist
1. 问题: ERROR: relation "xxx_id_seq" does not exist 2. 出现原因:由于表中建立了自增字段,id定义为Serial 类型,当执行完 ...
- [PAClient Error] Error: E4356 File does not exist armv7
[PAClient Error] Error: E4356 File does not exist: /Users/tt/PAServer/scratch-dir/Administrator-snIO ...
- Spring Cloud / Spring Boot There was an unexpected error (type=Unauthorized, status=401). Full authentication is required to access this resource.
访问EndPoint时会出现没有权限 There was an unexpected error (type=Unauthorized, status=401). Full authenticat ...
- 安装SQL Servre2000时提示“command line option syntax error! type command /? for help”
问题: 当程序正在安装ms数据访问组件时,弹出错误提示框:command line option syntax error,type command/? for help,点击确定继续:到了程序正在安 ...
随机推荐
- Golang中文乱码问题
在学习golang读取文件的过程中,遇到中文显示乱码的问题!golang没有自带的编解码包,因此需要借助第三方包 解决方法: 引入第三发转码包:git clone https://github.com ...
- Java集合学习(8):LinkedList
一.概述 LinkedList和ArrayList一样,都实现了List接口,但其内部的数据结构有本质的不同.LinkedList是基于链表实现的(通过名字也能区分开来),所以它的插入和删除操作比Ar ...
- BootStrap简单table
效果图: 代码如下: <%-- Created by IntelliJ IDEA. User: 冷噫雪 Date: 2019/9/1 Time: 13:06 To change this tem ...
- maven nexus 私服搭建 Linux版
准备工作 已安装jdk 已安装maven 下载Nexus Repository OSS:https://www.sonatype.com/download-oss-sonatype 如果无法下载成功, ...
- 纯数据结构Java实现(7/11)(SegmentTree)
欢迎访问我的自建博客: CH-YK Blog.
- PAT 乙级 1010.一元多项式求导 C++/Java
设计函数求一元多项式的导数.(注:xn(n为整数)的一阶导数为nxn−1.) 输入格式: 以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过 1000 的整数).数字间以空格分隔. ...
- Selenium_webdriver+java通过读取firefox、chrome的cookie文件,实现自动登录
遇到过很多问题,通过查资料得出的最终结果!
- js动画--一个小bug处理下
对于上面的课程我们很好的处理了一个小bug,那么我们现在讲程序进行优化一下,前一节的程序中,我们处理处理的属性都是写死了的.为了我们能够很好的对某个属性进行操作的话.我们这样来设置. js文件 win ...
- ArcGIS 将自定义工具发布到ArcGIS Server,作为Geoprocessing Service
新建自定义工具过程可参考上一篇博客:http://www.cnblogs.com/oceanking/p/3933681.html 1.执行自定义工具.此步骤不可省略 打开ArcCatalog,双击自 ...
- 搭建hadoop的HA集群模式(hadoop2.7.3+hive+spark)
参考:http://blog.51cto.com/12824426/2177663?source=drh 一.集群的规划 Zookeeper集群:192.168.176.131 (bigdata112 ...