问题
I a lot of orders in my Factory
.
Our regular time to finish our job is 10 days but sometimes we promise to the customer that it will be shorter (lets assume 5 days).
I tried to build an SQL that order by the minimum Date of the two columns
:
SELECT id, Status, DeliveryDate, PromiseDate
FROM CustomerOrderT
WHERE Status > 2 and Status <7
ORDER BY CASE WHEN DeliveryDate > PromiseDate then PomiseDate ELSE DeliveryDate END;
But i get a problem message from ms access. maybe write it correctly The problem massage attached

Thank you
回答1:
In MS Access you have to use IIF instead of Case like this:
SELECT id, Status, DeliveryDate, PromiseDate
FROM CustomerOrderT
WHERE Status > 2 and Status <7
ORDER BY IIF(DeliveryDate > PromiseDate, PromiseDate, DeliveryDate);
来源:https://stackoverflow.com/questions/37695916/ms-access-vba-order-by-case-when