postgresql 实现查询出的数据为空,则设为0的操作
我就废话不多说了~
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
以上为个人经验,希望能给大家一个参考,也希望大家多多支持IT技术网。如有错误或未考虑完全的地方,望不吝赐教。
您可能感兴趣的文章:
- postgresql 补齐空值、自定义查询字段并赋值操作
- postgresql 13.1 insert into select并行查询的实现
- postgresql insert into select无法使用并行查询的解决
- 关于PostgreSQL错误日志与慢查询日志收集
- PostgreSQL 实现查询表字段信息SQL脚本
- 查询PostgreSQL占多大内存的操作