Subject | Re: [firebird-support] SQL Question Count() statistics |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2003-10-17T07:46:33Z |
On 17 Oct 2003 at 5:31, tanz_anthrox wrote:
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.
>Name True Count False CountBy many ways. SP is one of them. CASE is the second. A "plain SQL"
>------- --------------- ----------------
>John 2 4
>Marie 6 9
>Helen 6 0
>
>How Can I do this?
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.