Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select SQL and ORDER BY...defective?
Message
 
À
25/02/2000 01:27:06
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00337312
Message ID:
00337517
Vues:
13
David,

Thanks a lot.
I'll try this as soon as possible and let you know the results.

Have a nice day.

Réal
------------------------------------
>Sorry, I just noticed Foxpro 2.6, so replace the inner join syntax with a "WHERE" version:
>
>Let's see if I understand this correctly. You want the first client in the result to be the one with the oldest account, with all of his records in date order, then on to the next oldest account, with all of its records in date order....
>
>Try this. It's two SQL statements with a REPLACE command, but it will do the job.
SELECT 000000 AS clt_order, ;
>MIN(date) AS firstdate, ;
>clt_code AS ccode ;
>FROM invoice ;
>INTO TABLE inv_temp1 ;
>GROUP BY 3 ;
>ORDER BY 2
>
>* at this point you have a table with oldest invoice
>* for each customer, sorted by date (the table name
>* really should be a unique name that will not conflict
>* with any other user)
>
>* make the order usable in the next SQL SELECT
>SELECT inv_temp1
>REPLACE ALL clt_order WITH RECNO()
>
>* now do the final select
>SELECT date, clt_code ;
><b>FROM invoice, inv_temp1 ;
>WHERE clt_code = ccode ;</b>
>ORDER BY temp1.clt_order, date
Not very elegant, but it does the job. Others may have a simpler way, but I can't think of it.
Réal Philippon
www.ultra.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform