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,点击确定继续:到了程序正在安 ...
随机推荐
- idea注释类,方法
1.添加类注释:file-settings-file and code Templates-Class #if (${PACKAGE_NAME} && ${PACKAGE_NAME} ...
- vue脚手架中动态引用图片的办法
需要先导入: import logo_st_ga from '../assets/big_st_ga.png'; import logo_st_sp from '../assets/big_st_sp ...
- JAVA Coder 的《深入分析Java Web 技术内幕》读书笔记
本文基于<深入分析Java Web 技术内幕> <深入分析Java Web 技术内幕>,作者是 许令波,电子工业出版社.本文只是记录书本当中的精彩部分,作个人回顾和技术分享,请 ...
- Prometheus学习笔记(2)Prometheus部署
目录 Prometheus的安装配置启动 Prometheus的安装配置启动 1.Prometheus二进制安装 Prometheus下载链接:https://prometheus.io/downlo ...
- 微信小程序引入外部组件 iView Weapp
iview Weapp组件的使用方法: 1. 下载小程序组件库 (前提是你已经有了项目目录) 你可以直接去github把iView Weapp的代码下载下来,也可以用过npm来下载. github地址 ...
- 【Spring Boot】Spring Boot之利用Logstash将日志转换成以JSON的格式存储和输出
一.Logstash的作用 Logstash是一个完全开源的工具,它可以对日志进行收集.过滤,能非常方便地将日志转换成以JSON的格式存储和输出,并将其存储供以后使用. 二.整合Logstash的步骤 ...
- k8s管理存储资源
1. Kubernetes 如何管理存储资源 理解volume 首先我们学习 Volume,以及 Kubernetes 如何通过 Volume 为集群中的容器提供存储:然后我们会实践几种常用的 Vol ...
- PAT 乙级 1019.数字黑洞 C++/Java
题目来源 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字.一直重复这样做,我们很快会停在有 ...
- 201671010417 金振兴 实验十四 团队项目评审&课程学习总结
项目 内容 软件工程 https://www.cnblogs.com/nwnu-daizh/ 作业要求 https://www.cnblogs.com/sunmiaokun/p/11095027.ht ...
- 那周余嘉熊掌将得队对男上加男,强人所男、修!咻咻! 团队的Beta产品测试报告
作业格式 课程名称:软件工程1916|W(福州大学) 作业要求:Beta阶段团队项目互评 团队名称: 那周余嘉熊掌将得队 作业目标:项目互测互评 队员学号 队员姓名 博客地址 备注 221600131 ...