I have the following table
GroupID Sequence Name
1 10 Mary
1 25 Jack
1 17 Jill
2 3 Peter
2 42 Henry
2 50 Paul
The following query returns a string with the following lower sequence (10) for a given group (1) and the given sequence 17
SELECT TOP 1 *
FROM dbo.customerassignmentgroup
WHERE groupid = 1
AND SEQUENCE < (SELECT MAX(SEQUENCE)
FROM dbo.customerassignmentgroup i
WHERE i.groupid = customerassignmentgroup .groupid)
AND manualsequence < 17
ORDER BY SEQUENCE DESC
Is there any other way to do this? I try to avoid
WHERE i.groupid = customerassignmentgroup.groupid
in an internal query because I need to convert this to a query in SubSonic
Note. My database is SQL Server 2000
source
share