Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Christian Tabligan
  Where is Christian Tabligan?
 Bacolod City, Neg. Occ.
 Philippines
 Christian Tabligan
Subject: RE: duplicate record view (query)
Thread ID: 181867 Message ID: 181916 # Views: 2 # Ratings: 0
Version: Visual FoxPro 8 Category: Databases, Tables and SQL Server
Date: Monday, July 7, 2008 1:56:15 AM         
   



> >
> >
> >
* create some test data
> >  CREATE CURSOR test (fldA C(1))
> >  INSERT INTO test VALUES ("A")
> >  INSERT INTO test VALUES ("B")
> >  INSERT INTO test VALUES ("C")
> >  INSERT INTO test VALUES ("A")
> >  INSERT INTO test VALUES ("A")
> >  INSERT INTO test VALUES ("D")
> >  INSERT INTO test VALUES ("C")
> >  * get duplicates
> >  SELECT flda, COUNT(*) as ncount ;
> >  FROM test ;
> >  GROUP BY flda ;
> >  HAVING ncount > 1 INTO CURSOR junk 
> >  
> >  * Put result in one row
> >  CREATE CURSOR JUNK2 (FldDup M)
> >  SELECT junk
> >  m.lcScan = ''
> >  SCAN 
> >     m.lcScan = m.lcScan + ALLTRIM(fldA)+" = "+ALLTRIM(STR(ncount))+" AND "
> >  ENDSCAN 
> >  * Remove the last occurence of " AND"
> >  INSERT INTO JUNK2 VALUES (left(m.lcScan,LEN(ALLTRIM(m.lcScan))-4))
> >  SELECT junk2 
> >  BROWSE 
> > 

> >
> > I used memo field type in this test because there is no fixed field width with what you need.
> >
> >
> > Jun Tangunan
> >
> > "Get out of the past and look in the future."
> > http://weblogs.foxite.com/sandstorm36/
>
> Wow! You already knew SQL Statement?
>
> CriZ (,")
>
> "Everyone is entitled to their own opinion, but not their own facts."

Little by little. :-U However that COUNT(*) as ncount came from Eric.

That is why I love trying to solve other's problem. It gives me the chance to study some things which I normally don't encounter. ;-)

Jun Tangunan

"Get out of the past and look in the future."
http://weblogs.foxite.com/sandstorm36/

ENTIRE THREAD

duplicate record view (query) Posted by OM RAJAN @ 7/6/2008 1:21:19 PM
RE: duplicate record view (query) Posted by Eric den Doop @ 7/6/2008 1:34:01 PM
RE: duplicate record view (query) Posted by OM RAJAN @ 7/6/2008 1:47:54 PM
RE: duplicate record view (query) Posted by Jun Tangunan @ 7/6/2008 2:20:10 PM
RE: duplicate record view (query) Posted by OM RAJAN @ 7/6/2008 4:22:38 PM
RE: duplicate record view (query) Posted by Christian Tabligan @ 7/7/2008 1:48:29 AM
RE: duplicate record view (query) Posted by Jun Tangunan @ 7/7/2008 1:56:15 AM
RE: duplicate record view (query) Posted by Christian Tabligan @ 7/7/2008 2:04:39 AM
RE: duplicate record view (query) Posted by Andy Kramek @ 7/6/2008 2:39:02 PM
RE: duplicate record view (query) Posted by OM RAJAN @ 7/6/2008 2:12:23 PM