Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PostgreSQL中使用两列从列中获取数据并显示该数据?_Sql_Postgresql_Count_Pivot - Fatal编程技术网

如何在PostgreSQL中使用两列从列中获取数据并显示该数据?

如何在PostgreSQL中使用两列从列中获取数据并显示该数据?,sql,postgresql,count,pivot,Sql,Postgresql,Count,Pivot,以下是示例表: 我想要这样的输出: 使用条件聚合: select wf_name, count(*) filter(where crt_by = 'ADHOC') adhoc, count(*) filter(where crt_by = 'SCHEDULE') schedule from mytable group by wf_name 你好请提供问题中的信息,而不是不显示的图像。很抱歉,这些图像没有显示,我是第一次发布,但你得到了问题的要点,问得对吗?

以下是示例表:

我想要这样的输出:


使用条件聚合:

select wf_name,
    count(*) filter(where crt_by = 'ADHOC') adhoc,
    count(*) filter(where crt_by = 'SCHEDULE') schedule
from mytable
group by wf_name

你好请提供问题中的信息,而不是不显示的图像。很抱歉,这些图像没有显示,我是第一次发布,但你得到了问题的要点,问得对吗?