ich habe hier 2 Views und möchte die gerne in einen zusammenpacken. Dazu bräuchte ich aber irgendwie eine Variable oder so.
Kann mir da vielleicht bitte einer helfen?
Code: Alles auswählen
CREATE OR REPLACE VIEW billing_in AS
SELECT destinations_in.identify, destinations_in.datum, destinations_in.in_carrier, destinations_in.dauer, ( SELECT preisliste.preis
FROM preisliste
WHERE destinations_in.datum >= preisliste.datum AND destinations_in.dialcode = preisliste.dialcode AND destinations_in.in_carrier = preisliste.carrier
LIMIT 1)
FROM destinations_in;
Code: Alles auswählen
CREATE OR REPLACE VIEW destinations_in AS
SELECT call.identify, call.datum, call.in_carrier, call.dauer, ( SELECT preisliste.dialcode
FROM preisliste
WHERE call.ausgangsnummer ~~ (preisliste.dialcode || '%'::text) AND call.in_carrier = preisliste.carrier AND call.datum >= preisliste.datum
ORDER BY char_length(preisliste.dialcode) DESC
LIMIT 1) AS dialcode
FROM call
WHERE call.dauer > 0
ORDER BY call.identify;
CREATE OR REPLACE VIEW destinations_in AS
SELECT call.identify, call.datum, call.in_carrier, call.dauer, ( SELECT preisliste.dialcode
FROM preisliste
WHERE call.ausgangsnummer ~~ (preisliste.dialcode || '%'::text) AND call.in_carrier = preisliste.carrier and destinations_in.datum >= preisliste.datum AND
ORDER BY char_length(preisliste.dialcode) DESC
LIMIT 1) AS dialcode,
( SELECT preisliste.preis
FROM preisliste
WHERE call.datum >= preisliste.datum AND destination_in.dialcode = preisliste.dialcode AND call.in_carrier = preisliste.carrier
LIMIT 1)
FROM call
WHERE call.dauer > 0 AND destinations_in.datum >= preisliste.datum
ORDER BY call.identify;
das wäre, wenn ich die beiden Views zu einem umbaue.
Kann man noch mehr zusammenfassen? zum beispiel wenn ich die beiden Orangen kreterien einfach an die lila stelle setze und das orange weg mache, geht das dann auch?
Gruß BoOnOdY