Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help on SQL to Retrive Data
Message
De
06/02/2013 02:15:00
 
 
À
06/02/2013 01:58:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01565237
Message ID:
01565239
Vues:
50
>I have a table which contains two columns namely
>
>attribute(c)
>Accountno (n)
>
>The data is as follows
>
>Attribute				Accountno
>
>GOOD					12345256
>GOOD					12345256
>GOOD					12345256
>GOOD					67569856
>FAIR					65957514
>FAIR					65957514
>AVG					99628522
>AVG					65957514
>AVG					12345256
>
>
>In the above table you could see that the account number 12345256 has repeated attribute for GOOD for 3 times. Similarly account Number has FAIR for two times.
>
>For my program, I need to have an attribute for only one time.
>So I need an SQL that could trace the repeated values of an attribute if the account number is same.
SELECT ;
  Accountno ;
  , Attribute ;
  , COUNT( * ) AS DupCount ;
  FROM MyTable ;
  INTO CURSOR Duplicates ;
  GROUP BY Accountno, Attribute ;
  HAVING DupCount > 1
Research GROUP BY and HAVING clauses in standard SQL to see how this works.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform