View mit Mehrfacher Countabfrage?

Hallo,

wie kann ich eine View mit mehrfachen Counts auf einer Tabelle mit unterschiedlichen Where Klauseln erstellen.
Dachte diese Form würde gehen, doch funktioniert das nicht.

select view test (rd,td) AS select
    count (*) from tabelle where bla = 'bla' from tabelle,
    count (*) from tabelle where bla = 'blub' from tabelle;

Dieses Beispiel geht zwar, doch kann ich da beide Where Klauseln nicht unterbringen.

select view test (rd,td) AS select
    count (*),
    count (*) from tabelle where bla = 'blub' from tabelle;

mfg
Marcus



test=*# create table drooper (bla text);
CREATE TABLE
test=*# copy drooper from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> bla
>> bla
>> blubb
>> foo
>> bar
>> batz
>> \.
test=*# select count(case when bla = 'bla' then 1 else 0 end) as anzahl_bla, sum(case when bla='blubb' then 1 else 0 end) as anzahl_blubb from drooper ;
 anzahl_bla | anzahl_blubb
------------+--------------
          6 |            1
(1 row)

test=*#

Daraus einen VIEW zu bauen überlasse ich Dir zur Übung.

Andreas

Super, dank dir!

mfg
Marcus

Ich hoffe, Du hast den von mir eingebauten Fehler gefunden g

Andreas