博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL的case when
阅读量:4585 次
发布时间:2019-06-09

本文共 587 字,大约阅读时间需要 1 分钟。

select tt.dict_label as display_item,t1.ratio from (select t.product_level,round(sum(case when t.detect_result='2' then 1 else 0 end)::NUMERIC/count(1)::NUMERIC,4) as ratio from t_detect_record t where t.district='3' and t.e_commerce_platform='3' group by t.product_level) t1 left join t_dict tt on t1.product_level=tt.dict_value where tt.dict_type='product_level'

select country, sum( case when sex = '1' then   population else 0 end),  --男性人口

 

 sum( case when sex = '2' then  population else 0 end)   --女性人口

 

from table_a   group by country;

 

转载于:https://www.cnblogs.com/esther-qing/p/5908955.html

你可能感兴趣的文章
【菜鸟学Python】函数的定义及调用
查看>>
宜信微服务任务执行器
查看>>
POJ 2774 Long Long Message 后缀数组
查看>>
datagrid中设置编辑,删除列是否可以访问
查看>>
Linux下I/O复用 Select与Poll
查看>>
python全栈学习--day10(函数进阶)
查看>>
Android初学第19天
查看>>
Flask框架web开发
查看>>
【linux就该这么学】-08
查看>>
JavaScript基础知识汇总
查看>>
PyQt4网格布局
查看>>
PHP学习笔记 - 进阶篇(3)
查看>>
极角排序那些事
查看>>
Ganglia+nagios 监控hadoop资源与报警
查看>>
博客园主题样式修改教程
查看>>
TextView实现多个TextView对象的走马灯效果
查看>>
感悟成功
查看>>
学员管理示例:Ajax删除学生
查看>>
线程组和未处理的异常
查看>>
Oracle管理监控之为11g asm磁盘组添加磁盘
查看>>