Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql counting duplicates, possible
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01620702
Message ID:
01620741
Vues:
42
You can also eliminate that extra step and use curDups as derived table instead, e.g. put that select with () in the second select statement to use it as derived table.

Or you can keep the current approach in 2 steps.

>
>select min(mRec) as MinVs, MDate, COUNT(*) as cntDups ;
>from ch5 ;
>GROUP BY MDate ;
>HAVING COUNT(*) > 1 into cursor curDups NOFILTER
>SELECT T.*, IIF(T.mRec = curDups.MinVs, 1, 0) as KeepInfo, curDups.cntDups, curDups.minVs ;
>from ch5 T INNER JOIN curDups ON T.MDate = curDups.MDate into cursor curFinal nofilter
>
>
>>>Here it is. Using min(Vs), keepInfo found the first in alphabetical order. Using min(mRec), keepInfo found the top record in each group.
>>>
>>>
>>>mDate-----------Vs-----mRec-----keepInfo----cntdups---minVs
>>>05/28/2013-----menu------2---------1----------3---------2
>>>05/28/2013-----conso-----3---------0----------3---------2
>>>05/28/2013-----dire------4---------0----------3---------2  
>>>08/28/2013-----henr-----18---------1----------2---------2
>>>08/28/2013-----tran-----19---------0----------2---------2
>>>09/16/2013-----texa-----25---------1----------2---------2
>>>09/16/2013-----key------26---------0----------2---------2
>>>
>>>
>>>Thank you very much again!!!
>>>STeve
>>>
>>
>>You're welcome.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform