SQL CE: Limiting rows returned in the query
Posted
by Diakonia7
on Stack Overflow
See other posts from Stack Overflow
or by Diakonia7
Published on 2009-12-17T20:00:30Z
Indexed on
2010/05/23
2:20 UTC
Read the original article
Hit count: 452
In SQL Compact Edition 3.5 , note that it is the Compact Edition I am talking about- Is there a way to limit the amount of rows to only 2? Something like using LIMIT or TOP. I really don't want to use anything with a SqlCEDataReader, or SqlCEResultSet. I want to do all the limiting in the query. Is this possible now? I have looked around and it doesn't seem so.
EDIT-
In response to Dave Swersky's request for data and using Min()/Max() on some columns as a means to get the top 2 lines, here is some sample (sterilized) data:
Line Site Function Status
1010 Las Vegas new 4
1020 DC send 1
1030 Portland copy 1
1040 SF copy 1
1050 Portland copy 1
1060 DC send 1
*There are more columns than this but these are the significant ones.
Sorry for the lack of intuitive data (but the actual data is even less intuitive!), but for security i need to change the data.
So- i need to determine: what site the record was at in the preceding line to determine where it needs to be picked up.
The site on any given line (except the first line with function = 'new') corresponds to where the item is going next. So simply grabbing that site off the same line wont tell me where it came from. The status will always be 1 or 4. The 4 corresponds to a where it has been delivered already and so i dont want to include those records in the result. But it might be useful in getting the pickup site.
For this table of data i want the query to return the site corresponding to the line just above the first line with status 1. So- for this it would be Las Vegas.
© Stack Overflow or respective owner