MS Access中的条件字段

时间:2016-10-26 16:44:15

标签: sql ms-access ms-access-2010

我在MS Access中有以下SQL查询

SELECT 
   Laufzettel.ANTRAGSNUMMER, 
   Laufzettel.Versicherungsnummer, 
   DP.DUNKEL,   
   Laufzettel.AEingangDatenstromZWorkflow,
   Laufzettel.BEingangesigniertDokumentZWorkflow,
   Laufzettel.CAusgangDatenstromZWorkflow,
   Laufzettel.DAnlageSchwebeVSL, 
   Laufzettel.EPolicierungVSL
FROM 
   DP, Laufzettel;

DP.DUNKEL只是一个单值1.我希望只有当Laufzettel.EPolicierungVSL不为NULL时才显示DP.DUNKEL否则显示0.我怎么能实现这一点,因为我无法找到IF ELSE SQL中的条件?

2 个答案:

答案 0 :(得分:1)

在MS Access中,您可以使用内联IIF(条件,真,假)

在你的情况下。

    # Now get all PRs and filter by whether or not they belong to the
    # milestone; requesting them all at once is still faster than
    # requesting one at a time. This would also be easier if the API
    # supported sorting on PR lists
    for pr in self.iter_pull_requests(state='closed'):
        if (pr['number'] not in milestone_issues or not pr['merged_at']):
            continue

        merge_commit = self.get_pull_request_merge_commit(pr['number'])

        # Ignore commits that were merged before the last tag date
        if merge_commit['commit']['committer']['date'] < last_tag_date:
            continue

        if not self.find_merged_commit(merge_commit,
                                       since=last_tag_date):
            yield pr, merge_commit['sha']

注意:由于您的dunkle列可以计算,因此您不需要DP表。 (或者至少我在SQL中看不到任何需要)

答案 1 :(得分:0)

可能正在使用swithc

  SELECT 
        Laufzettel.ANTRAGSNUMMER
      , Laufzettel.Versicherungsnummer
        Switch(
          Not IsNull (Laufzettel.EPolicierungVSL),  DP.DUNKEL
          IsNull (Laufzettel.EPolicierungVSL),  0 
          ) AS dunkel
      , Laufzettel.AEingangDatenstromZWorkflow
      , Laufzettel.BEingangesigniertDokumentZWorkflow
      , Laufzettel.CAusgangDatenstromZWorkflow
      , Laufzettel.DAnlageSchwebeVSL
      , Laufzettel.EPolicierungVSL
  FROM DP, Laufzettel;