您现在的位置是:网站首页> 编程资料编程资料
postgresql 实现查询出的数据为空,则设为0的操作_PostgreSQL_
2023-05-27
571人已围观
简介 postgresql 实现查询出的数据为空,则设为0的操作_PostgreSQL_
我就废话不多说了~
select name,price from odoo_sale;

select name,COALESCE(price, 0) from odoo_sale;

补充:postgresql查询某列的最大值时,对查询结果为空做默认为0的处理
实例如下:
select coalesce(max(max_grade),0) from exam_grade where examinee_id = 12345 and exam_id = 1;
查询某个考生在某个指定试卷的最高分,如果没有,则返回0
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。
您可能感兴趣的文章:
相关内容
- postgresql 补齐空值、自定义查询字段并赋值操作_PostgreSQL_
- PostgreSQL 实现定时job执行(pgAgent)_PostgreSQL_
- Postgres 创建Role并赋予权限的操作_PostgreSQL_
- pgsql之create user与create role的区别介绍_PostgreSQL_
- postgresql 切换 log、xlog日志的实现_PostgreSQL_
- postgresql 利用xlog进行热备操作_PostgreSQL_
- Postgresql中xlog生成和清理逻辑操作_PostgreSQL_
- Postgresql去重函数distinct的用法说明_PostgreSQL_
- postgresql 12版本搭建及主备部署操作_PostgreSQL_
- 使用pg_basebackup对Postgre进行备份与恢复的实现_PostgreSQL_
