Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wrong Result
Message
From
06/07/2008 09:14:45
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Wrong Result
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01329221
Message ID:
01329221
Views:
51
Dear Experts
create cursor crsalp2 ;
(date d(8),acc_code c(7),tittle c(40),code2 c(7),acc_name c(7),;
qty n(4),balance n(8))
insert into crsalp2 values ({^2008-07-02},'3401002','APPLE','2404131','ERIC',5,0)
insert into crsalp2 values ({^2008-07-02},'2404131','ERIC','3401002','APPLE',0,0)
insert into crsalp2 values ({^2008-07-02},'3401002','APPLE','2404198','BORIS',10,0)
insert into crsalp2 values ({^2008-07-02},'2404198','BORIS','3401002','APPLE',0,0)
insert into crsalp2 values ({^2008-07-02},'3401002','APPLE','2404131','ERIC',5,0)
insert into crsalp2 values ({^2008-07-02},'2404131','ERIC','3401002','APPLE',0,0)
 

f_date1={^2008-07-02}
t_date1={^2008-07-02}

SET ENGINEBEHAVIOR 70

q2 = "csr" + sys(2015)

select tittle_a,tittle_b, sum(qty),code2,acc_code,balance;
from ;
( select distinct t1.tittle,t2.tittle, t1.qty,t1.code2,t1.acc_code,t1.balance;
from crsalp2 t2 ;
join crsalp2 t1 ;
on t1.acc_code=t2.code2 and t1.code2=t2.acc_code;
where t1.qty>0 and between(t1.date,f_date1,t_date1);
order by t1.tittle , t2.tittle) as q1;
group by tittle_a,tittle_b ;
into cursor q2 readwrite

brow

SUM SUM_qty TO total_qty
Problems

1- ERIC purchased 10 apples but it says 5
2- TOTAL apple quantity is 20 but it says 15

The data in table is an example,
the actual table has more than fify product and party codes.

Please help
Next
Reply
Map
View

Click here to load this message in the networking platform