請教關于表中數據處理問題
CH.DBF
idate movt in_QTY
2013/5/1 A 100
2013/5/20 A 50
2013/5/1 b 100
2013/5/20 b 50
ch表中第月會有兩次來貨in_QTY,日期未定。MOVT有上百種品名,現要求成如下格式
MOVT in_qty_1 in_qty_2
A 100 50
B 100 50
這個在EXCEL中很容易實現,在VFP中我不知道如何比較快捷。
另外上述數據要排列成另外一種形式,就是日期由月頭至月尾,數量沒有的為0
idate movt in_QTY
2013/5/1 A 100
2013/5/2 A 0
2013/5/3 A 0
......
2013/5/19 A 0
2013/5/20 A 50
2013/5/21 A 0
...
2013/5/31 A 0
2013/5/1 b 100
2013/5/2 b 0
2013/5/3 b 0
......
2013/5/19 b 0
2013/5/20 b 50
2013/5/21 b 0
...
2013/5/31 b 0
這兩個問題應該怎么解決呢,如果能用SELECT解決最好
[解决办法]
第二个问题代码如下:
Set Century On
Set Date Japan
Select Distinct movt From ch Into Cursor cu1
ym=[201305]&&年月
date_min=Ctod(Left(ym,4)+[/]+Right(ym,2)+[/01])&&当月第一天的日期
date_max=Gomonth(date_min,1)-1&&当月最后天的日期
Create Cursor cu2 (idate D,movt c(1))
Select cu1
Scan
Select cu2
i=date_min
Do While i<=date_max
Append Blank
Replace idate With i,movt With cu1.movt
i=i+1
Enddo
Endscan
Select cu2.idate,cu2.movt,Iif(Isnull(ch.in_qty),0,ch.in_qty) As in_qty ;
from cu2 Left Join ch On cu2.idate=ch.idate And cu2.movt=ch.movt Order By cu2.movt,cu2.idate Into Cursor cu3
Browse
[解决办法]
2
SELECT MAX(IDATE) AS MA,MIN(IDATE) AS MI FROM R:\TEMP\TTQ INTO CURSOR DD
AM=DD.MA
AI=DD.MI
CREATE CURSOR TT(ADATE DATE)
DO WHILE AI<=AM
INSERT INTO TT VALUES(AI)
AI=AI+1
ENDD
SELECT * INTO CURSOR dd1 READWRITE FROM (;
SELECT *,00000.00 AS in_QTY FROM TT,(SELECT DISTINCT movt FROM R:\TEMP\TTQ) A;
UNION ALL;
SELECT * FROM R:\TEMP\TTQ) a1
SELECT adate,movt,SUM(in_QTY) FROM dd1 GROUP BY adate,movt ORDER BY movt,adate
[解决办法]
把你的样表和要得到的结果表都传上来。
传到这里:http://www.access911.net/CSDN/