Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Showing last 10 records using rowcount, or some other way
Mon, Dec 31 2012 1:31 PMPermanent Link

John Postnikoff

I am trying to do something like this below in a C/S application. I would like to get the last 10 orders for a customer. I see there is a range option, however I am not sure if that would work for me when the data is constantly changing by the minute.

SET ROWCOUNT 10 SELECT * FROM DeliveryOrders WHERE CustomerAccount = 2039
ORDER BY DeliveryDate

John Postnikoff
Mon, Dec 31 2012 2:16 PMPermanent Link

Raul

Team Elevate Team Elevate

John,

Range is exactly what you need. Nor sure what your table looks like but
you'd need to use something like this:

SELECT * FROM DeliveryOrders
WHERE customerAccount=2039
ORDER BY OrderData DESC
RANGE 1 TO 10

The range limits you to 10 and descending sort by OrderDate ensures you
get last 10 (replace the orderdate by whatever field in your table
determines the proper ordering)

Raul



On 12/31/2012 1:31 PM, John Postnikoff wrote:
> I am trying to do something like this below in a C/S application. I would like to get the last 10 orders for a customer. I see there is a range option, however I am not sure if that would work for me when the data is constantly changing by the minute.
>
> SET ROWCOUNT 10 SELECT * FROM DeliveryOrders WHERE CustomerAccount = 2039
> ORDER BY DeliveryDate
>
> John Postnikoff
>
Mon, Dec 31 2012 8:58 PMPermanent Link

John Postnikoff


Thanks Raul!  That worked awesome for me.


Raul wrote:

John,

Range is exactly what you need. Nor sure what your table looks like but
you'd need to use something like this:

SELECT * FROM DeliveryOrders
WHERE customerAccount=2039
ORDER BY OrderData DESC
RANGE 1 TO 10

The range limits you to 10 and descending sort by OrderDate ensures you
get last 10 (replace the orderdate by whatever field in your table
determines the proper ordering)

Raul



On 12/31/2012 1:31 PM, John Postnikoff wrote:
> I am trying to do something like this below in a C/S application. I would like to get the last 10 orders for a customer. I see there is a range option, however I am not sure if that would work for me when the data is constantly changing by the minute.
>
> SET ROWCOUNT 10 SELECT * FROM DeliveryOrders WHERE CustomerAccount = 2039
> ORDER BY DeliveryDate
>
> John Postnikoff
>
Image