Subject Re: SQL Question Count() statistics
Author tanz_anthrox
Thanx Dimitry

You wrote : "SP is one of them" You mean storedProcedure ??
I tried to make StoredProcedure like

CREATE PROCEDURE COUNTNAMES
RETURNS (
TRUTH INTEGER,
FAITH INTEGER)
AS
BEGIN
SELECT Name,
(SELECT count(*) FROM table t2
WHERE t1.Name=t2.Name and t2."True/False"="T")
as "True count",
(SELECT count(*) FROM table t2
WHERE t1.Name=t2.Name and t2."True/False"="F")
as "False count"
FROM table t1
GROUP by Name
INTO :TRUTH,:FAITH;
SUSPEND; /* I DONT KNOW WHY !!*/
END

But this procedure returns a RESULT SET not a ROW;
How Can I implement this by using Stored Procedure.

Regards



--- In firebird-support@yahoogroups.com, "Dimitry Sibiryakov"
<SD@t...> wrote:
> On 17 Oct 2003 at 5:31, tanz_anthrox wrote:
>
> >Name True Count False Count
> >------- --------------- ----------------
> >John 2 4
> >Marie 6 9
> >Helen 6 0
> >
> >How Can I do this?
>
> By many ways. SP is one of them. CASE is the second. A "plain
SQL"
> solution:
>
> SELECT Name,
> (SELECT count(*) FROM table t2
> WHERE t1.Name=t2.Name and t2."True/False"="T")
> as "True count",
> (SELECT count(*) FROM table t2
> WHERE t1.Name=t2.Name and t2."True/False"="F")
> as "False count"
> FROM table t1
> GROUP by Name
>
> SY, Dimitry Sibiryakov.