ms访问查询每次都返回不一致的结果

时间:2014-09-17 04:18:58

标签: sql ms-access

我有一个Access SQL数据库,我在SQL中查询(而不是通过设计视图屏幕),但是每次运行时查询都会返回不同数量的记录。大多数情况下,它返回986行,但有时它只返回985行(丢失的行永远不会是与上次相同的缺失行),有时它甚至返回984行甚至982行。

我有选择地删除了部分SQL并运行它,当SQL包含SWITCH函数时,我似乎得到了不一致的结果:

SELECT 
  BU.vcrName AS [Business Unit], 
  Team.vcrName AS Team, 
  TmplHdr.vcrName AS Template, 
  Tmpl.intVersion AS Version,
  switch(Tmpl.dtmCreated is not null and Tmpl.dtmCompleted is null and Tmpl.dtmDeactivated is null, "In Development",
         Tmpl.dtmCompleted is not null and Tmpl.dtmAuthorised is null and Tmpl.dtmDeactivated is null, "Awaiting Authorisation",
         Tmpl.dtmAuthorised is not null and Tmpl.dtmDeactivated is null and Tmpl.intId in (select intId from qryLiveTemplates), "Live",
         Tmpl.dtmAuthorised is not null and Tmpl.dtmDeactivated is null and Tmpl.intId not in (select intId from qryLiveTemplates), "Inactive",
         Tmpl.dtmDeactivated is not null, "Deactivated",
     true, "unknown status") as Status,
  TmplHdr.intId as TemplateHeaderId
FROM 
  ((TblBusinessUnit AS BU INNER JOIN TblTeam AS Team ON BU.intId = Team.intBusUnitId) 
   INNER JOIN TblTemplateHeader AS TmplHdr ON Team.intId = TmplHdr.intTeamId) 
   INNER JOIN TblTemplate AS Tmpl ON TmplHdr.intId = Tmpl.intTemplateHeaderId
ORDER BY BU.vcrName asc, Team.vcrName asc, TmplHdr.vcrName asc, Tmpl.intVersion DESC;

鉴于底层源数据(保存在该数据库中的表中)没有变化,有没有人有任何建议,为什么每次运行它都会返回不同的结果?

0 个答案:

没有答案
相关问题