Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Aggregate Field..
Message
De
04/06/2001 01:26:52
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Aggregate Field..
Divers
Thread ID:
00514417
Message ID:
00514417
Vues:
40
Hi All,

In case of using GROUP BY in SQL-SELECT, The Last record of criteria
is selected for each group though there is no aggregate field.
But I heard it's unreliable. Here is my code.

** because records are not inserted in the order of date,
** select all records from table sorted by desired order
** before real SQL.
** Though mytable has INDEX for custid+dtos(date) and I open
** with proper order with another alias, SQL only tells phisically
** saved last record.

lcAlias=SYS(2015)
select custid,date,debt,custid+dtos(date);
FROM myTable ;
where date < someday;
into cursor (lcAlias) order by 4

** get the last debt of each custid
select custid,MAX(date),debt from (lcAlias);
GROUP BY CUSTID into cursor myCursor
** select custid,date,debt from (lcAlias);
** GROUP BY CUSTID into cursor myCursor

Though I can have the last debt and date per custid correctly,
I'm not so sure My way is correct.
And in ther 2nd-Query, Regardless of using MAX() I have the
same result. I need an advice what is the most reliable way
to get the last record of some specific order.

Any comments would be appreciated.

RGDS
HK.Lee
MCP
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform