 |
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
kinvanhon
註冊時間: 2014-10-07 文章: 1
第 1 樓
|
發表於: 星期四 十月 30, 2014 4:05 pm 文章主題: 請教各位大大,怎麼實現分組自動添加序號 |
|
|
像這樣
|
|
回頂端 |
|
 |
lygcw9603
註冊時間: 2011-12-25 文章: 130
第 2 樓
|
發表於: 星期日 十一月 02, 2014 10:00 am 文章主題: |
|
|
代碼: |
[size=18]*方法一
Create Cursor Tt (A1 C(1),A2 N(2),A3 N(2))
Insert Into Tt (A1) Values ("a")
Insert Into Tt (A1) Values ("a")
Insert Into Tt (A1) Values ("c")
Insert Into Tt (A1) Values ("b")
Insert Into Tt (A1) Values ("d")
Insert Into Tt (A1) Values ("c")
Insert Into Tt (A1) Values ("b")
Insert Into Tt (A1) Values ("b")
Insert Into Tt (A1) Values ("b")
Replace All A2 With Recno()
Update Tt Set Tt.A3=(Select Count(*)+1 From Tt B Where Tt.A2<B.A2 And Tt.A1=B.A1) FROM Tt
Select * From Tt Order By A1,A3
**********************************************************
* 方法二
Create Cursor Tt (A1 C(1),A2 N(1))
Insert Into Tt (A1) Values ("a")
Insert Into Tt (A1) Values ("a")
Insert Into Tt (A1) Values ("c")
Insert Into Tt (A1) Values ("b")
Insert Into Tt (A1) Values ("d")
Insert Into Tt (A1) Values ("c")
Insert Into Tt (A1) Values ("b")
Insert Into Tt (A1) Values ("b")
Insert Into Tt (A1) Values ("b")
Select A1,Count(*) nJs From Tt Group By A1 Into Cursor Temp
Scan
Select Tt
lnI=1
Scan For A1==Temp.A1 And lnI<=Temp.nJs
Replace A2 With lnI
lnI=lnI+1
EndScan
EndScan
Select * From Tt Order By A1 | [/size] |
|
回頂端 |
|
 |
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|