Re: How to retieve previous rows based on query results
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 23:32:31 +0100
On Wed, 10 Jan 2007 12:27:02 -0800, John wrote:
Currently retieving data based on some column criteria, but now need to
retrieve previous record based on results.
Ex:
Seq. # User Ranch
Seq. 54 Thomas Smith Texas Ranch
Because users met Texas Ranch Criteria, now I would like also to display on
report record for Seq 53
Hi John
If I take your question literally, the answer would be:
SELECT ....
FROM your table
WHERE SeqNo = 'Seq. 53';
But I guess your question involves more than this. So I suggest that you
begin by posting the following:
* CREATE TABLE statements for the table(s) involved. Please include all
constraints, indexes and properties. You may omit irrelevant columns and
their constraints, indexes and properties,
* INSERT statements with a few well-chosen rows of sample data to
illustrate the problem,
* Expected resuls the the sample data provided,
* A short explanation of what you are trying to do,
* And, if applicable, any code you may already have written as failed
attempts.
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.
- Prev by Date: Re: Cannot add the data into the table
- Next by Date: The multi-part identifier could not be bound
- Previous by thread: Re: Insert data
- Next by thread: The multi-part identifier could not be bound
- Index(es):
Relevant Pages
|
|