Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Union and Group by clause
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01457617
Message ID:
01457623
Views:
101
This message has been marked as the solution to the initial question of the thread.
You would need UNION ALL and derived table
	SELECT Ch1, SUM(ncount) AS ncount FROM ( ;
	  SELECT Temp1.Ch1 ,;
	    COUNT(Temp1.Ch1) AS NCOUNT  GROUP BY 1 FROM Temp1;
	    UNION ALL ;
	    SELECT Temp2.Ch1,;
	    COUNT(Temp2.Ch1) AS NCOUNT  FROM Temp2 GROUP BY 1 ;
	    ) dt1 ;
	 GROUP BY ch1   ;
	 INTO CURSOR temp
>
>i want a single sql command .
>I WANT count a field of 2 tables with union clause
>
>I want 2 for result of ncount() && {^2009/10/01}
>
>
> m.d_debut = {^2009/10/01}
>
>  CREATE CURSOR Temp1 ( Ch1 D(8) )
>
>  INSERT INTO Temp1  VALUE( m.d_debut )
>  INSERT INTO Temp1  VALUE(m.d_debut + 1 )
>  INSERT INTO Temp1  VALUE(m.d_debut + 2 )
>  INSERT INTO Temp1  VALUE(m.d_debut + 3 )
>
>
>  CREATE CURSOR Temp2 ( Ch1 D(8) )
>  INSERT INTO Temp2  VALUE( m.d_debut )
>
>  SET ENGINEBEHAVIOR 90
>  SELECT Temp1.Ch1 ,;
>    COUNT(Temp1.Ch1) AS NCOUNT  GROUP BY 1 FROM Temp1;
>    UNION;
>    SELECT Temp2.Ch1,;
>    COUNT(Temp2.Ch1) AS NCOUNT  FROM Temp2;
>    GROUP BY 1 INTO CURSOR temp
>
>
>
>The result is bad...
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform