我是新手,雖然我已經花了幾個小時在谷歌上搜索解決方案,但我仍然無法解決這個問題 - 希望有人能幫助我,拜托!
我正在嘗試在 bash 中使用 while 回圈和 postgresql 查詢,該查詢將為 2018-01-01 和 2018-03-31 之間的每個日期回傳一個整數。使用我當前的查詢,我在 bash 中收到以下錯誤:
"HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
ERROR: operator does not exist: date = integer
LINE 8: WHERE event_date=2018-01-02"
我嘗試運行回圈的方式(通過 mcedit 撰寫腳本)是:
#!/usr/bin/env bash
d=2018-01-01
while [ "$d" != 2018-04-01 ]; do.
psql -U dataguy -d postgres -c"
SELECT event_date, COUNT(DISTINCT(id)) as daily_active_users FROM
(SELECT event_type, country, id, CAST(NULL as INT) AS price, event_date FROM returners
UNION ALL
SELECT event_type, NULL AS country, id, CAST(NULL as INT) AS price, event_date FROM sub
UNION ALL
SELECT event_type, NULL AS country, id, price, event_date FROM buy) AS returners_sub_buy
WHERE event_date=$d
GROUP BY event_date;"
d=$(date -I -d "$d 1 day")
done
非常感謝任何建議、建議或提示!
uj5u.com熱心網友回復:
引數通常需要參考,例如
WHERE event_date='2018-01-02'
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/463921.html
標籤:PostgreSQL 重击
