Member Avatar for dmmckelv

Is there a keyword in SQL that would allow you to select a value from a field in the previous row? I am looking for something that would give me the speed field value for the row before:

SELECT min(Parsed.Time), [Parsed.Number]
FROM Parsed
GROUP BY [Parsed.Rev Number]

You can always use join two tables using row_number()...

Member Avatar for dmmckelv

You can always use join two tables using row_number()...

My rows are not numbered. Any other suggestions?

Thanks!

Hello dmmckelv,

When Edgar Frank Codd invited relational databases his primary idea was to found it on
logic algebra and set theory. The rows of relational tables (aka relations) are sets. Therefore, there aren't duplicate rows nor any particular order of rows. From this point of view, "I am looking for something that would give me the speed field value for the row before" is rather irrelevant.

However, to put any meaningful signification on it, your table must already have a column
which allows such an ordering, for example date, timestamp or auto-increment numbers.
If you don't have such special column (or set of columns) within a table, it is impossible to determine the predecessor of a specific row because the today predecessor could be the successor row tomorrow (e.g. due to inserting and deleting rows in the meantime).

To cut a long story short, what's that special column of your table to get particularly ordered rows? You may also post the creating statement of your table.

-----
tesu

commented: You didn +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.