需要按Access Query中的Expression排序

时间:2014-10-09 21:10:08

标签: sql ms-access

然而,我有一个表达式正在撤回我需要的确切数据 Access不允许我按它排序......这使得数据几乎无用。

查询设计器中的表达式:

DelDays: Workdays(Format([Shipment Date]+1,'0000-00-00'),Format([POD Delivery Date],'0000-00-00'))

这是SQL查询:

SELECT RTGFDXGround.[Invoice Number], RTGFDXGround.[Express or Ground Tracking ID], RTGFDXGround.[Service Type], RTGFDXGround.[Shipment Date], RTGFDXGround.[POD Delivery Date], RTGFDXGround.[Net Charge Amount], RTGFDXGround.[Zone Code], Workdays(Format([Shipment Date]+1,'0000-00-00'),Format([POD Delivery Date],'0000-00-00')) AS DelDays, Mid([Recipient Zip Code],1,5) AS ToZip, RTGFDXGround.[Shipper Zip Code]
FROM RTGFDXGround
WHERE (((RTGFDXGround.[Invoice Number])="6788") AND ((RTGFDXGround.[Ground Tracking ID Prefix])<>"715"))
ORDER BY RTGFDXGround.[Zone Code] DESC , Mid([Recipient Zip Code],1,5) DESC;

有关如何通过'DelDays'DESC对此进行排序的任何建议? 我更喜欢逻辑在Queries中工作,而不需要使用Report。

一如既往地谢谢!

1 个答案:

答案 0 :(得分:1)

使用SQL,您可以将内容放入子查询中并使用结果。

SELECT *
FROM
(
  SELECT RTGFDXGround.[Invoice Number], RTGFDXGround.[Express or Ground Tracking ID], RTGFDXGround.[Service Type], RTGFDXGround.[Shipment Date], RTGFDXGround.[POD Delivery Date], RTGFDXGround.[Net Charge Amount], RTGFDXGround.[Zone Code], Workdays(Format([Shipment Date]+1,'0000-00-00'),Format([POD Delivery Date],'0000-00-00')) AS DelDays, Mid([Recipient Zip Code],1,5) AS ToZip, RTGFDXGround.[Shipper Zip Code]
  FROM RTGFDXGround
  WHERE (((RTGFDXGround.[Invoice Number])="6788") AND ((RTGFDXGround.[Ground Tracking ID Prefix])<>"715"))
)
ORDER BY DelDays DESC
相关问题