Re: How to retieve previous rows based on query results



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
.



Relevant Pages

  • Re: Query syntax for count comparison
    ... Vyas, MVP (SQL Server) ... with 2 columns each: Seq# and Client. ... If so, please provide correct syntax. ...
    (microsoft.public.sqlserver.clients)
  • Re: DLOOKUP FOR NEXT
    ... >My intention is to extract from my table; base, lot, seq and next seq from ... >the sample data below. ... I've included my DLOOKUP query below, ...
    (microsoft.public.access.queries)