Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with the order

Status
Not open for further replies.

marvinjmd

Programmer
Jan 23, 2003
68
US
i have a problem i couldn´t solve in about 2 months.... i have a table with the sits in a baseball stadium... thay are arrange in: type of seat, section,row and seat number.. of course i want to index in that order... but there are a section with an "AA" & "AAA" an even "AB" rows the indexes i create order in this order
ORDER ORDER I WANT
A A 1 A AAA 1
A A 2 A AA 1
A AA 1 A A 1
A AAA 1 A A 2

i try many combinations... none work... please.. how i could make that??

MANY THANKS IN ADVANCE
 
How about:

Code:
index on section + padl(alltrim(row), 3, '[') + padl(tran(seat), 3, '0') tag SeatOrder additive

This assumes that seat is an integer -- you'll have to adjust the code a bit if that's not the case.

Putting the '[' in the row sorts the single letters last, the double letters second-last and the triple letters first. '[' is chr(91), one more than 'Z' (chr(90)).

Cheers,

Andrew

Cheers,

Andrew Coates
OzFox 2003 Australia's VFP Conference -- ------
DISCLOSURE
We are the Australasian Distributor for the Hentzenwerke Series of Books. (By the same token, I really do think they're the best printed VFP resource out there -- that's why we sell them)
 
try the following

create table baseball (type c(10), section c(10), number c(10) )
* code to add data to this table
index on type+str(len(section)-len(alltrim(section))) +number tag baseball

(in this example i have assumed the 3 fields are all character fields)

Pete Bloomfield
Down Under
 
Oops -- I left out the seat type (which doesn't appear in your sample data. You could use:

Code:
index on seat_type + section + padl(alltrim(row_name), 3, '[') + padl(tran(seat), 3, '0') tag SeatOrder additive

Note that it's not a good idea to call the type column "Type" or the row column "row" because they are VFP reserved words and this could lead to problems later.

Cheers,

Andrew

Andrew Coates
OzFox 2003 Australia's VFP Conference -- ------
DISCLOSURE
We are the Australasian Distributor for the Hentzenwerke Series of Books. (By the same token, I really do think they're the best printed VFP resource out there -- that's why we sell them)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top