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,点击确定继续:到了程序正在安 ...
随机推荐
- DLL Injection with Delphi(转载)
原始链接 I had recently spent some time playing around with the simple to use DelphiDetours package from ...
- C++编写动态库(.DLL)给C#调用方法
1.在头文件中按照如下格式编写函数申明 extern "C" __declspec(dllexport) double __stdcall Add(double a, double ...
- pip换源-换成国内的源
PyPI使用国内源 通过几次 pip 的使用,对于默认的 pip 源的速度实在无法忍受,于是便搜集了一些国内的pip源,如下: 阿里云 http://mirrors.aliyun.com/pypi ...
- Python使用Thrift
2019年07月30日 14:59:29 Shower稻草人 阅读数 25更多 分类专栏: Python 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接 ...
- 算法 翻转二叉树 dfs
翻转二叉树 翻转一棵二叉树.左右子树交换. Example 样例 1: 输入: {1,3,#} 输出: {1,#,3} 解释: 1 1 / => \ 3 3 样例 2: 输入: {1,2,3,# ...
- docker学习8-搭建nginx环境
前言 使用 docker 搭建 nginx 环境 下载镜像 使用docker pull 拉取最新的 nginx 镜像 [root@yoyo ~]# docker pull nginx Using de ...
- xargs的用法
处理带有空格的文件名 #我们创建了3个日志文件, 且故意让文件名称中都含有空格 [roc@roclinux ~]$ ;i<;i++)); do touch "test ${i}.log ...
- List的复制 (浅拷贝与深拷贝)
开门见山的说,List的复制其实是很常见的,List其本质就是数组,而其存储的形式是地址 如图所示,将List A列表复制时,其实相当于A的内容复制给了B,java中相同内容的数组指向同一地址,即进行 ...
- Ruby for
#!/usr/bin/ruby -w# -*- coding: UTF-8 -*-for i in 1..5 print i," "endprint "\n"f ...
- Reducetask机制
Reduce大致分为copy.sort.reduce三个阶段,重点在前两个阶段.copy阶段包含一个eventFetcher来获 取已完成的map列表,由Fetcher线程去copy数据,在此 ...