使用UNION ALL won进行查询';我不能用html写

使用UNION ALL won进行查询';我不能用html写,html,postgresql,Html,Postgresql,我有一个包含UNION all语句的查询,我想将其写入html文件,但它只执行列并在其中写入0。 我怎样才能通过呢? 我的问题是: /usr/bin/psql -h localhost -U etaxi_prod_due etaxi_prod_due --html -c "with summary as (select count(id) as \"Summary\" from archived_order where data like '%"pmi":2568%' and finishe

我有一个包含UNION all语句的查询,我想将其写入html文件,但它只执行列并在其中写入0。 我怎样才能通过呢? 我的问题是:

/usr/bin/psql -h localhost -U etaxi_prod_due etaxi_prod_due --html -c "with summary as (select count(id) as \"Summary\" from archived_order 
where data like '%"pmi":2568%' 
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Summary\" from archived_order 
where data like '%"pmi":2569%' 
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Summary\" from archived_order 
where data like '%"pmi":2570%'
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Summary\" from archived_order
where data like '%"pmn":"CHILD_SEAT"%'
and finished between current_date - interval '1 day' and current_date
), app as 

(select count(id) as \"Etaximo\" from archived_order
where data like '%"pmn":"CHILD_SEAT"%'
and finished between current_date - interval '1 day' and current_date), oper as

(select count(id) as \"Operator\" from archived_order 
where data like '%"pmi":2568%' 
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Operator\" from archived_order 
where data like '%"pmi":2569%' 
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Operator\" from archived_order 
where data like '%"pmi":2570%'
and finished between current_date - interval '1 day' and current_date), sumcompl as 

(select count(id) as \"Summary Completed\" from archived_order 
where data like '%"pmi":2568%' and completed is true
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Summary Completed\" from archived_order 
where data like '%"pmi":2569%' and completed is true 
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Summary Completed\" from archived_order 
where data like '%"pmi":2570%' and completed is true
and finished between current_date - interval '1 day' and current_date

UNION ALL

select count(id) as \"Summary Completed\" from archived_order
where data like '%"pmn":"CHILD_SEAT"%' and completed is true
and finished between current_date - interval '1 day' and current_date
), result1 as (
select 
sum(\"Summary\") as \"Created\"
from summary
), result2 as 
(select 
sum(\"Summary Completed\") as \"Done\"
from sumcompl
), result3 as (select
sum(\"Operator\") as \"Operator\"
from oper
), result4 as (select
sum(\"Etaximo\") as \"Etaximo\"
from app 
)
select result1.\"Created\", result2.\"Done\", result3.\"Operator\", result4.\"Etaximo\" from result1, result2, result3, result4 order by result1.\"Created\", result2.\"Done\", result3.\"Operator\", result4.\"Etaximo\";">>/home/www/etaxi-prod-due/tmp/shara.html
我试着做了一些
groupby
orderby
的工作,但是没有任何帮助,我还试着做了一些类似于封装的事情,使它看起来像是html中没有联合的东西。但它也不起作用

此查询的html文件输出如下所示:

<table border="1">
  <tr>
    <th align="center">Created</th>
    <th align="center">Completed</th>
    <th align="center">Operator</th>
    <th align="center">Etaximo</th>
  </tr>
  <tr valign="top">
    <td align="right">0</td>
    <td align="right">0</td>
    <td align="right">0</td>
    <td align="right">0</td>
  </tr>
</table>
<p>(1 row)<br />
</p>

创建
完整的
操作人员
依他肟
0
0
0
0
(1行)

但应该是这样

<table border="1">
  <tr>
    <th align="center">Created</th>
    <th align="center">Completed</th>
    <th align="center">Operator</th>
    <th align="center">Etaximo</th>
  </tr>
  <tr valign="top">
    <td align="right">193</td>
    <td align="right">152</td>
    <td align="right">161</td>
    <td align="right">32</td>
  </tr>
</table>
<p>(1 row)<br />
</p>

创建
完整的
操作人员
依他肟
193
152
161
32
(1行)


如果它不是html,它会提供什么输出?你能用当前输出更新你的帖子吗?看起来你的一些双引号没有被转义。这可能是问题所在吗?将SQL放在一个文件中,然后用
-f
标志调用
psql
可以接受吗?我明白了。如果是这样的话,你能试着用herdeoc代替
-c
?您的一些
WHERE
子句使用了未转义的双引号(即
“%”“pmi”:2568%“