Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select with additional conditions
Message
From
14/11/2007 10:10:56
 
 
To
14/11/2007 07:32:10
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01268865
Message ID:
01268906
Views:
11
OK, Problem solved...
SET enginebehavior 90

SELECT A.ddate,;
B.Block,;
C.cname as name,;
C.narea as area,;
ROUND(iif(not isnull(c.nspx) and not isnull(c.nspy) and C.nspx<>0 and C.nspy<>0,C.narea*(43560/(C.nspx*C.nspy)),C.nrdmPlants),2) as Plants,; 
ROUND(D.plants,2) as TotPlants,;
ROUND((A.nmen/D.plants)* iif(not isnull(c.nspx) and not isnull(c.nspy) and C.nspx<>0 and C.nspy<>0,ROUND(C.narea*(43560/(C.nspx*C.nspy)),0),C.nrdmPlants),2) as Spread, ;
C.nspx as spx,C.nspy as spy,A.nmen as Men;
FROM Dailywork2 A ;
Inner Join Block2 B ;
On A.cblock=B.block ;
Left Outer JOIN ;
BlockProfile C ON A.cblock = C.cparent;
Left OUTER Join ;
(select C.cparent,sum(iif(not isnull(c.nspx) and not isnull(c.nspy) and C.nspx<>0 and C.nspy<>0,C.narea*(43560/(C.nspx*C.nspy)),0))+(SUM(C.nrdmPlants))as Plants ;
FROM BlockProfile C  group by cparent WHERE BETWEEN(dailywork2.ddate ,C.dstart,C.dend)) D ;
on D.cparent=A.cblock ;
WHERE BETWEEN(A.ddate ,C.dstart,C.dend)
The 2 Betweens have done the trick! Wonder why I wasn't getting this result before...

Steve
Previous
Reply
Map
View

Click here to load this message in the networking platform