Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.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
Excel 我的数据在postgres数据库中。示例数据和所需输出如下所示_Excel_Postgresql_Excel Formula_Postgresql 9.1_Postgresql 9.3 - Fatal编程技术网

Excel 我的数据在postgres数据库中。示例数据和所需输出如下所示

Excel 我的数据在postgres数据库中。示例数据和所需输出如下所示,excel,postgresql,excel-formula,postgresql-9.1,postgresql-9.3,Excel,Postgresql,Excel Formula,Postgresql 9.1,Postgresql 9.3,我很难弄明白这一点。有人能看看这张图片并提供一个解决方案吗。 请不要给出涉及任何脚本语言编码的解决方案,因为我不是编程人员。 我想通过sql查询(postgres)或在excel中使用excel公式来解决这个问题。我没有要测试的postgres(因此这可能并不完美)。此解决方案假定一个开口id不超过两个位置 Select t1.opening_id Case when t2.Num >1 THEN CONCAT(t1.location,' | ',t2.location) ELSE t

我很难弄明白这一点。有人能看看这张图片并提供一个解决方案吗。 请不要给出涉及任何脚本语言编码的解决方案,因为我不是编程人员。
我想通过sql查询(postgres)或在excel中使用excel公式来解决这个问题。

我没有要测试的postgres(因此这可能并不完美)。此解决方案假定一个
开口id
不超过两个
位置

Select 
t1.opening_id
Case when t2.Num >1 THEN 
CONCAT(t1.location,' | ',t2.location)
ELSE t1.location END as location
,AVG(t1.days_open,t2.days_open) as days_open
,t1.age_band
from table t1
INNER JOIN(
           Select 
           opening_id
           ,location
           ,AVG(days_open)
           ,COUNT(distinct location) as Num
           from table
           Group by opening_id
                   ,location
           )t2
ON t1.opening_id=t2.opening_id
Group by 
        t1.opening_id
       ,t2.Num
       ,CONCAT(t1.location,'|',t2.location)
       ,t1.location
       ,t1.age_band