SELECT 1 - Cast (a.count AS FLOAT) / Cast (b.count AS FLOAT) AS percentage
FROM
(SELECT Count(DISTINCT request_id) FROM quotes) AS a,
(SELECT Count(*)
FROM requests
WHERE user_id IS NOT NULL AND state NOT IN ( 'rejected', 'unconfirmed' )) AS b
请求和引号表都有created_at时间列。
我应该把这一行放在哪里
date_trunc('week', quotes.created_at + '1 day'::interval) AS "week_num"
获取百分比截断的百分比表?