I am trying to execute the following query but it is showing a warning 1292
CREATE VIEW fr1
AS
SELECT
country, state, city, docname, price1, discunt, tot4,
tech1, remarks3, remarks4,
EXTRACT(YEAR_MONTH FROM ddd) AS month1,
CASE
WHEN docname = 'Dr. Mariam' OR 'Dr. Dania Dilshad' AND (tot4 - zzz4) > 0
THEN 100 - (zzz3 + 15)
ELSE zzz1
END AS nzzz1,
CASE
WHEN docname = 'Dr. Mariam' OR 'Dr. Dania Dilshad' AND (tot4 - zzz4) > 0
THEN 15
ELSE zzz2
END AS nzzz2,
CASE
WHEN remarks4 = 'Card'
THEN tot4 * 0.02
ELSE 0
END AS dedcharge,
zzz3, zzz4, zzz5
FROM
iap4
When using multiple conditions in the OR clause, you need to group them properly with parentheses to ensure the correct evaluation
the "OR" condition should be like this
docname = 'Dr. Mariam' OR docname = 'Dr. Dania Dilshad'
here is the full updated query
CREATE VIEW fr1 AS
SELECT
country,
state,
city,
docname,
price1,
discunt,
tot4,
tech1,
remarks3,
remarks4,
EXTRACT(YEAR_MONTH FROM ddd) as month1,
CASE
WHEN (docname = 'Dr. Mariam' OR docname = 'Dr. Dania Dilshad') AND (tot4 - zzz4) > 0 THEN 100 - (zzz3 + 15)
ELSE zzz1
END as nzzz1,
CASE
WHEN (docname = 'Dr. Mariam' OR docname = 'Dr. Dania Dilshad') AND (tot4 - zzz4) > 0 THEN 15
ELSE zzz2
END as nzzz2,
CASE
WHEN remarks4 = 'Card' THEN tot4 * 0.02
ELSE 0
END as dedcharge,
zzz3,
zzz4,
zzz5
FROM iap4;