Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT question
Message
De
03/04/1998 10:15:05
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/04/1998 09:23:07
Shane Gilbert
Oklahoma State Department of Education
Norman, Oklahoma, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00089237
Message ID:
00089256
Vues:
17
>I have a table with about 16000 records in it. These are monthly claims. The table contains original, and revised claims. The original claims have claims.crecno = 0, and each revision to that claim increments the crecno by 1. So for any month, there is an original and from 0 to many revisions. I want a SELECT that I can retrieve the latest revised claims for a given month into a cursor. So that if the client just sent in the original(crecno=0) I get the original claim, but if there are any revisions, I get the claim with the highest(crecno).
>Table: claims
>co n2
>dist c4
>month n2
>year n4
>crecno n2
>data...
>
>str(co,2)+dist is the customer number
>
>I want something like:
>SELECT * FROM claims WHERE month = 12 AND year = 1997 AND Max(crecno);
>INTO CURSOR claimlist
>
>Any suggestions?
>
>Shane
Shane,
I think you should do it in two SQL.
select str(co,2)+dist, ;
       str(co,2)+dist+padl(crecno,2,"0") as identifier ,;
       max(crecno) ;
  from claims ;
  WHERE month = 12 AND year = 1997 ;
  group by 1 ;
  where .t. ;
  into cursor pass1
SELECT * FROM claims ;
  WHERE str(co,2)+dist+padl(crecno,2,"0") in ;
       (select identifier from pass1) ;
       INTO CURSOR claimlist
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform