Ich suchte bereits auf Google für diese, aber immer noch kann ich nicht die richtige Lösung für mein Problem bekommen.SQL-Abfrage in Where-Klausel-Gruppe von
Alles, was ich will, ist das Ergebnis in jedem Feld in Where-Klausel zu erhalten. Hier ist mein Code:
BEGIN
-- INSERT INTO tmp_sr_accountsales (REFERENCENO, CUSTOMER, TransDate, SALESTYPE, STDTERMS, Amount)
SELECT act.referenceno,
act.customer,
act.atdate transdate,
act.salestype,
cust.stdterms,
Ifnull(act.totalamount, 0)- Ifnull(act.discountamnt, 0) AS amount,
Ifnull(act.totalamount, 0)- Ifnull(act.discountamnt, 0) AS amount2,
Ifnull(act.totalamount, 0)- Ifnull(act.discountamnt, 0) AS amount3,
Ifnull(act.totalamount, 0)- Ifnull(act.discountamnt, 0) AS amount4,
Ifnull(act.totalamount, 0)- Ifnull(act.discountamnt, 0) AS amount5,
intyear AS intyear,
intyear1 AS intyear2,
intyear2 AS intyear3,
intyear3 AS intyear4,
intyear4 AS intyear5
FROM 100 _actual_transaction act
INNER JOIN 000 _customer cust
ON (
act.customer = cust.customername)
WHERE (
act.referenceno IS NOT NULL
AND act.customer LIKE thecustomer
AND act.salestype LIKE thesalestype
AND (
year(act.atdate) IN(intyear,
intyear1,
intyear2,
intyear3,
intyear4)));
END;
Wenn Sie den Code sehen:
WHERE
(
act.REFERENCENO IS NOT NULL
AND act.CUSTOMER LIKE theCustomer
AND act.SALESTYPE LIKE theSalesType
AND(
YEAR(act.ATDATE) IN(
intYear,
intYear1,
intYear2,
intYear3,
intYear4
)
)
);
That ein, die innerhalb der IN (intYear,intYear1,intYear2,intYear3,intYear4)
war sie unterschiedlichen Jahreswert. und ich möchte das Ergebnis von jedem von ihnen bekommen. Ist es möglich, ihr Ergebnis 1 zu 1 zu bekommen? Da das Ergebnis dieses Codes nur alle Daten hinzufügen wird, die in dieser Abfrage ausgewählt wurden.
Tag des dbms Sie‘ wieder verwenden. (Einige produktspezifische Funktionen wurden verwendet.) – jarlh
Versuchen Sie, die Codeformatierung zu verbessern. Wenn ich zum Lesen blättern muss, gehe ich einfach. – jarlh
Dies ist kein SQL Server. Die 'IFNULL'-Funktion existiert dort nicht. –