| | |
Select Previous Row Values
Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2006
Posts: 32
Reputation:
Solved Threads: 0
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:
MS SQL Syntax (Toggle Plain Text)
SELECT min(Parsed.Time), [Parsed.Number] FROM Parsed GROUP BY [Parsed.Rev Number]
Last edited by dmmckelv; Jul 18th, 2008 at 4:58 am. Reason: more specific
•
•
Join Date: Apr 2008
Posts: 296
Reputation:
Solved Threads: 42
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
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
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
![]() |
Similar Threads
- How to include FLV videos in php (PHP)
- trying to make a survey for school yearbook, need help (PHP)
- Hi guys please clear my doubt. (ASP.NET)
- Need Help With Program (VB.NET)
- mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- PHP/SQL query help (PHP)
Other Threads in the MS SQL Forum
- Previous Thread: Urgent Help needed.....
- Next Thread: [Help] Procedure
| Thread Tools | Search this Thread |





