将查询结果写入html

时间:2019-12-26 15:08:56

标签: html postgresql

我有一个带有UNION的查询,并且其中包含过滤器。 我想用包含在查询中的命令用html编写它。 我该怎么办?

/usr/bin/psql -h localhost -U etaxi_prod_due etaxi_prod_due --html -c "with cte as (
select count(id) filter (where data like '%"pmn":"CHILD_SEAT"') as \"Summary\",
       count(id) filter (where data like '%"pmn":"CHILD_SEAT"' and completed is true) as \"Summary Completed\",
       'Etaximo заказы'
from archived_order 
where created_user_login like 'exchangeAgent@shara'
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2568%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2568%' and completed is true) as \"Summary Completed\",
       'Детское кресло 1-3 Эконом'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":4%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2568%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2568%' and completed is true) as \"Summary Completed\",
       'Детское кресло 1-3 Стандарт'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":1%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2568%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2568%' and completed is true) as \"Summary Completed\",
       'Детское кресло 1-3 Комфорт'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":2%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2568%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2568%' and completed is true) as \"Summary Completed\",
       'Детское кресло 1-3 Бизнесс'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":3%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2568%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2568%' and completed is true) as \"Summary Completed\",
       'Детское кресло 1-3 Универсал'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":5%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2569%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2569%' and completed is true) as \"Summary Completed\",
       'Детское кресло 3-7 Эконом'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":4%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2569%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2569%' and completed is true) as \"Summary Completed\",
       'Детское кресло 3-7 Стандарт'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":1%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2569%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2569%' and completed is true) as \"Summary Completed\",
       'Детское кресло 3-7 Комфорт'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":2%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2569%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2569%' and completed is true) as \"Summary Completed\",
       'Детское кресло 3-7 Бизнесс'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":3%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2569%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2569%' and completed is true) as \"Summary Completed\",
       'Детское кресло 3-7 Универсал'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":5%' 
  and created between current_date - interval '1 day' and current_date
  UNION ALL

select count(id) filter (where data like '%"pmi":2570%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2570%' and completed is true) as \"Summary Completed\",
       'Детское кресло 7-12 Эконом'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":4%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2570%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2570%' and completed is true) as \"Summary Completed\",
       'Детское кресло 7-12 Стандарт'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":1%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2570%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2570%' and completed is true) as \"Summary Completed\",
       'Детское кресло 7-12 Комфорт'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":2%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2570%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2570%' and completed is true) as \"Summary Completed\",
       'Детское кресло 7-12 Бизнесс'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":3%' 
  and created between current_date - interval '1 day' and current_date

UNION ALL

select count(id) filter (where data like '%"pmi":2570%') as \"Summary\",
       count(id) filter (where data like '%"pmi":2570%' and completed is true) as \"Summary Completed\",
       'Детское кресло 7-12 Универсал'
from archived_order 
where created_user_login not like 'exchangeAgent@shara' 
  and data like '%"cci":5%' 
  and created between current_date - interval '1 day' and current_date
), result as (
select 
  sum(\"Summary\") \"Summary\", 
  sum(\"Summary Completed\") \"Summary Completed\",
  null \"Type of seat\"
from cte
union all
select * from cte)
select * from result;" >>/home/www/etaxi-prod-due/tmp/shara.html

希望对此问题有所帮助。 我尝试进行封装以避开UNION ALL,但是它不起作用,所以我没有想法。 我试图完全重写它,但是它似乎也不起作用。因此,如果您有一些想法,请告诉我。

0 个答案:

没有答案