Urgent--Newbie, please Help!:-)--TOP 10 Plus Increments of the next TOP 10

Urgent--Newbie, please Help!:-)--TOP 10 Plus Increments of the next TOP 10

Post by James Jako » Sat, 28 Apr 2001 08:33:21



Hi,

does anyone know of a Query that will return the first TOP 10 and then
the following TOP 10 in increments fof 10??

I have 2 QUERIES which will return the first TOP 10, but not the next
increments of 10.

Here are 2 QUERIEs  I am using just to return the TOP 10:

1)

SET ROWCOUNT 10
SELECT contact_id
FROM contacts
ORDER BY contact_id asc

2)

SELECT top 10 contact6_Id
FROM contacts
ORDER BY contact_id ASC
These both work, but can't figure out how to get the next increments
of 10.

3) also tried this a suggested, but it returns bottom 10 --not what I
need.

SELECT TOP 10 contact_id
FROM contacts
WHERE contact_id in
(SELECT TOP 20 contact_id
FROM contacts

 
 
 

Urgent--Newbie, please Help!:-)--TOP 10 Plus Increments of the next TOP 10

Post by Carl » Sat, 28 Apr 2001 10:58:26


Use a derived table.  Here's an example for Northwind that gets the first
item shipped of the last 10.  Many ways to do this, but this syntax is
similar to what you have been using.

use northwind
go

select top 1 *
from
(SELECT top 10 * FROM Orders
order by ShippedDate DESC) LastTenOrders
order by LastTenOrders.ShippedDate


Quote:> Hi,

> does anyone know of a Query that will return the first TOP 10 and then
> the following TOP 10 in increments fof 10??

> I have 2 QUERIES which will return the first TOP 10, but not the next
> increments of 10.

> Here are 2 QUERIEs  I am using just to return the TOP 10:

> 1)

> SET ROWCOUNT 10
> SELECT contact_id
> FROM contacts
> ORDER BY contact_id asc

> 2)

> SELECT top 10 contact6_Id
> FROM contacts
> ORDER BY contact_id ASC
> These both work, but can't figure out how to get the next increments
> of 10.

> 3) also tried this a suggested, but it returns bottom 10 --not what I
> need.

> SELECT TOP 10 contact_id
> FROM contacts
> WHERE contact_id in
> (SELECT TOP 20 contact_id
> FROM contacts


 
 
 

1. Urgent--Newbie, please Help!:-)--TOP 10 Plus Increments of the next TOP 10

Hi,

does anyone know of a Query that will return the first TOP 10 and then
the following TOP 10 in increments fof 10??

I have 2 QUERIES which will return the first TOP 10, but not the next
increments of 10. Also, does anyone know the QUERRY to return the
BOTTO 10 as well?

Here are 2 QUERIEs  I am using just to return the TOP 10:

1)

SET ROWCOUNT 10
SELECT contact_id
FROM contacts
ORDER BY contact_id asc

2)

SELECT top 10 contact6_Id
FROM contacts
ORDER BY contact_id ASC
These both work, but can't figure out how to get the next increments
of 10.

3) also tried this a suggested, but it returns bottom 10 --not what I
need.

SELECT TOP 10 contact_id
FROM contacts
WHERE contact_id in
(SELECT TOP 20 contact_id
FROM contacts
ORDER BY contact_id DESC)
ORDER BY contact_id ASC

Thanks in advance. Any help will be greatly appreciated.

James

2. Problem when upgrading MDAC 2.1 to 2.5

3. Oracle DBA needed - Enjoy your job!

4. US-TX-OO DESIGNER/DEVELOPER - JAVA

5. $$FREE TO START - $000s PER MONTH $$

6. SELECT TOP 10 & next 10 Increments

7. How to Select TOP 10 and next TOP 10 increments?

8. Top 10 and Top 1 in an MDX statement (Foodmart 2000)