I have a dataset that contains:
Table { date itemName }
The date for the most part is sequential. There are no duplicates of the date [as it is the primary key].
The question is split up into multiple parts (all with respect to using SQL):
1/2/09-1/3/09
are missing n = 2
Dates 1/2/09-1/3/09
are not returned but Dates 5/6/09-6/1/09
are.A sequence in PostgreSQL is a user-defined schema-bound object that yields a sequence of integers based on a specified specification. The CREATE SEQUENCE statement is used to create sequences in PostgreSQL. Now let's analyze the above syntax: First, set the name of the sequence after the CREATE SEQUENCE clause.
A Sequential Scan (or Seq Scan) reads the rows from the table, in order. Sequential scans can be the fastest way of getting a row from a small table, and the fastest way of getting a high proportion of the rows from larger tables.
There is essentially no difference.
If you can use PostgreSQL 8.4 then window functions will help:
SELECT *
FROM (SELECT itemName, date, date - lag(date) OVER w AS gap
FROM someTable WINDOW w AS (ORDER BY date)
) AS pairs
WHERE pairs.gap > '1 day'::interval;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With