Sunday, 11 August 2013

Is it possible to write a query to compare rows to other rows in same table?

Is it possible to write a query to compare rows to other rows in same table?

I have a table with the following structure. I need to return all rows
where the district of the record immediately preceding and immediately
following the row are different than the district for that row. Is this
possible? I was thinking of a join on the table itself but not sure how to
do it.
id | zip_code | district
__________________________
20063 10169 12
20064 10169 9
20065 10169 12

No comments:

Post a Comment