MS ACCESS VBA ORDER BY CASE When

那年仲夏 提交于 2019-12-12 03:47:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!