...insert into results (commandid) select * from generate_series(1,1000); delete from results where random() < 0.20; This works: SELECT s.i AS missing_cmd FROM generate_series(0,1000) s(i) WHERE NOT EXISTS (SELECT 1 FROM results WHERE...
FROM (SELECT '2014-10-31'::date - 1 AS day) d -- effective date here , Generate_series(0,3) w ). W JOIN requests r ON r."date" BETWEEN w_start AND w_end GROUP BY w.w, r.accounts_id HAVING sum(r.amount) > 10 ) sub GROUP BY 1 HAVING count(*) = 4; Step 1. In the innermost subquery w...
SELECT curr_date, SUM(count). FROM generate_series (curr_date-8, curr_date-1, '1 day'::interval) d. LEFT JOIN m.ping AS p ON p.date = d.
SELECT subcategory(t) FROM task t; You can use this however in any part of the select statement including the where clause.
INSERT INTO small_1 SELECT i, i FROM generate_series(1,100000) s(i); -- different cardinality (second column 10 values).
Generate a series of values, from start to stop with a step size of step. When step is positive, zero rows are returned if start is greater than stop.
from generate_series(1, 1000). ; CREATE EXTENSION permuteseq; CREATE TABLE uniq_tstamp(t timestamp)
Before we can use our handy random ID generating cipher, we need to register it as a function within Postgres. In this case we are actually going to register two separate functions. One that generates the “random” ID, and the other that ensures we respect the min/max bounds. These functions are written...
INSERT INTO entity(store) SELECT ''::hstore FROM generate_series(6000001,10000000) AS i