SELECT TOP 1
CostValue
FROM
[~client_table~].[dbo].[CostRules] AS CostRule
WHERE
(CASE
WHEN DATALENGTH(CostRule.ModelName) = 0
THEN
CostRule.Type = 1
AND CostRule.Manufacturer = Printer.ManufacturerId
AND CostRule.ColorType = 1
ELSE
CostRule.Type = 2
AND CostRule.ModelName = Printer.ModelName
AND CostRule.ColorType = 1
END
)
) AS MonoCost
Ich möchte meine WHERE-Anweisung in Abhängigkeit von der Datenlänge von CostRule.ModelName
definieren. Aber ich habe einen Fehler: Incorrect syntax near '='
. in CostRule.Type = 1
und ich habe einen Fehler in der ELSE
Aussage.SQL - WHERE mit CASE-Anweisung
Das ist was ich will! Vielen Dank. –