Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Crosstab sorting question
Message
From
17/08/2007 08:48:54
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01248074
Message ID:
01248745
Views:
38
Thanks!

>Hi Yossi,
>
>The columns are ordered by their name which is derived from values in the 'column field'. You have 2 options:
>
  • Change values in the 'column field' so columns are ordered the way you want. That's what you're doing now
    >
  • Generate and run post-query to rearange columns.
    >
    >In either case you can use a table or cursor when column order is defined for each value in the 'column field' .
    >
    >>Maybe I didn't make myself clear.
    >>
    >>Run the follwing program and tell me how to sort by birth date so that the order of the columns is cust3, cust2, cust1.
    >>
    >>
    >>CLOSE all
    >>
    >>CREATE CURSOR PreXtab (row C(10), col C(10), data C(10))
    >>
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Shoe Size', 'cust1', '8')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Birth Date', 'cust1', '1/1/90')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('cat name', 'cust1', 'sue')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Shoe Size', 'cust2', '9')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Birth Date', 'cust2', '1/1/89')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('cat name', 'cust2', 'alex')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Shoe Size', 'cust3', '11')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Birth Date', 'cust3', '1/1/88')
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('cat name', 'cust3', 'ruffles')
    >>				
    >>DO HOME() + "VFPXTab" WITH "RawXTab",.T.,.F.,.T.,1,2,3,.F.,0,.T.
    >>
    >>My solution is to prepend the birthdate to the column field like so:
    >>
    >>
    >>INSERT INTO PreXtab (row, col, data)   ;
    >>VALUES ('Shoe Size', '19900101cust1', '8')
    >>
    >>
    >>and then in the report construct the column header like so:
    >>
    >>
    >>substr(field(1),9)
    >>
    >>
  • Previous
    Reply
    Map
    View

    Click here to load this message in the networking platform