akretschmer
Datenbank-Guru
- Beiträge
- 10.334
select count(maschinen.typ), maschinen_typen.typ from ...
Da ist keine dritte Spalte.
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
select count(maschinen.typ), maschinen_typen.typ from ...
Und wie das unterbewußt war...wenn er sogar dazu schreibt "kenne mich mit dem Syntax aber kaum aus", oder so. (vl. unterbewusste handlung, oder so)
select count(maschinen.typ), maschinen_typen.typ, count(maschinen.typ) from maschinen_typen left join maschinen on (maschinen_typen.id = maschinen.typ) group by maschinen_typen.typ
select anzahl.count from (select count(maschinen.id) from maschinen group by maschinen.typ) as anzahl
select * from (select count(maschinen.id) from maschinen group by maschinen.typ) as anzahl
select count from (select count(maschinen.id) from maschinen group by maschinen.typ) as anzahl
create or replace function freie_m_nach_typ(x integer) returns table (anzahl bigint) as 'select count(maschinen.id)
from maschinen
where maschinen.id not in (select vermietungen.maschinen_id from vermietungen where mietzeit @> now()::timestamp) and maschinen.typ = x group by maschinen.typ'
language sql
select count(maschinen.id), maschinentypen.typ, freie_m_nach_typ(maschinen.typ) from maschinen inner join maschinentypen on (maschinentypen.id = maschinen.typ) group by maschinentypen.typ, maschinen.typ
count | typ | freie_m_nach_typ
-------+-------------------+------------------
1 | Coverlockmaschine | 1
1 | Stickmaschine | 1
2 | Overlockmaschine | 2
3 | Mitgebrachte | 3
4 | Haushaltsmaschine | 3
(5 rows)