I have a table with the following fields: id, date, testrecord. What I want
to do is to order the table so that the records are ordered as follows: id
by date by testrecord. I want id to be in ascending order, but date and
testrecord in descending order. I created an index file called testdata with
the expression: id+dtoc(date,1)+testrecord. Id and testrecord are character
fields.This index file will sort in ascending order. My question is: what do
I need to do to get the table sorted as I want it - that is id in ascending
order, but date and testrecord in descending order?

Re: Indexing a table on multiple fields with a date field in descending order by Fred

Fred
Sat Aug 12 14:36:15 CDT 2006

Do you need an actual index, or just a "view" for reporting purposes? If
for reporting only, I'd suggest creating a cursor with a SELECT statement
using an ORDER BY since each field in the order by can be ascending or
descending as needed. If you really have to have an index, you can do:

id+TRANSFORM(99999999-VAL(DTOS(date))+testrecord

--
Fred
Microsoft Visual FoxPro MVP


"Jack McAfee" <jacksonkmcafee@bellsouth.net> wrote in message
news:p6pDg.8998$qd.7790@bignews3.bellsouth.net...
>I have a table with the following fields: id, date, testrecord. What I want
> to do is to order the table so that the records are ordered as follows: id
> by date by testrecord. I want id to be in ascending order, but date and
> testrecord in descending order. I created an index file called testdata
> with
> the expression: id+dtoc(date,1)+testrecord. Id and testrecord are
> character
> fields.This index file will sort in ascending order. My question is: what
> do
> I need to do to get the table sorted as I want it - that is id in
> ascending
> order, but date and testrecord in descending order?
>
>
>



Re: Indexing a table on multiple fields with a date field in descending order by AA

AA
Sun Aug 13 04:17:44 CDT 2006

SELECT * FROM Mytable ORDER BY id ASC, date DESC, testrecord DESC INTO
CURSOR Q1
-Anders

"Jack McAfee" <jacksonkmcafee@bellsouth.net> skrev i meddelandet
news:p6pDg.8998$qd.7790@bignews3.bellsouth.net...
>I have a table with the following fields: id, date, testrecord. What I want
> to do is to order the table so that the records are ordered as follows: id
> by date by testrecord. I want id to be in ascending order, but date and
> testrecord in descending order. I created an index file called testdata
> with
> the expression: id+dtoc(date,1)+testrecord. Id and testrecord are
> character
> fields.This index file will sort in ascending order. My question is: what
> do
> I need to do to get the table sorted as I want it - that is id in
> ascending
> order, but date and testrecord in descending order?
>
>
>