Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete duplicate records
Message
From
27/11/2006 12:25:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/11/2006 07:43:10
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01172620
Message ID:
01172712
Views:
19
This message has been marked as the solution to the initial question of the thread.
>Dear Experts,
>
>Table1 has three fields as
>
>date---------d(8)
>voucher-----n(4)
>type---------c(2)
>
>data in table is as follows
>
>25/11/06----1----SL
>25/11/06----1----SL
>25/11/06----2----SL
>25/11/06----2----SL
>25/11/06----2----SL
>25/11/06----1----SD
>25/11/06----1----SD
>25/11/06----1----SD
>
>I want to delete more than two records according to following index file
>
>select table1
>index on dtoc(date)+str(voucher)+allltrim(type) to xyz
>
>after processing the data in table should look like this
>
>25/11/06----1----SL
>25/11/06----1----SL
>25/11/06----2----SL
>25/11/06----2----SL
>25/11/06----1----SD
>25/11/06----1----SD
>
>The number of same records is two.
>
>Please help
local nCnt
SELECT * FROM table1 ;
  HAVING COUNT(*) > 2 ;
  GROUP BY date,voucher,type ;
  INTO CURSOR xx nofilter
scan
  SCATTER memvar
  SELECT table1
  LOCATE FOR date = m.date AND voucher = m.voucher AND type = m.type
  nCnt = 1
  DO WHILE FOUND()
    CONTINUE
    nCnt = nCnt + 1
    IF m.nCnt > 2
      delete
    endif
  ENDDO
  SELECT xx
endscan
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
Previous
Reply
Map
View

Click here to load this message in the networking platform