SELECT TOP 10 *
FROM MyTable where (name = 'John' and ID >= 5) or
(name !='John' and name > 'John')
ORDER BY
case when name = 'John' and ID = 5 then 0 else 1 end,
NAME,ID
it's ok.
I find that if exist more rows with field name = 'John'
and I have table ordered by NAME, rows are sorted by NAME + ID (id is primary key in MyTable). I think It must to use.
SELECT TOP 10 *
FROM MyTable where name >= 'John'
ORDER BY
case when name = 'John' and ID = 5 then 0 else 1 end
...
Hi Dan.
MyTable is only example to explain situation. In other case table will has other data and I don't start with John of course.
In my example I know only, that first row in my result has Name = John and Id = 5, plus I want next 9 rows in order by name.
I want to use this code for scrolling...
Hi,
I use MsSQL 7.0
I have got easy table MyTable (order by NAME):
ID NAME AGE
-----------------
4 Boris 26
2 John 22
5 John 24 <---
3 John 23
1 Kevin 25
...
I would like retrieve 10 rows by SELECT statement, where first row has NAME = JOHN AND ID = 5...
Hello,
We are successfuly using a great piece of code, modNTLM (sets REMOTE_USER request variable to "PRAHA\Kolek_R" for example), on our intranet server. We are implementing security on "LOCATION" container (see uncommented part of httpd.conf bellow). Everything works fine...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.