在动态AOT查询中使用WHERE过滤器

时间:2017-10-02 23:26:09

标签: sql-server microsoft-dynamics dynamics-ax-2012 aot

我有这个SQL查询

def sample_func(txt=None, file_input=None, file_output=None):
    raw_txt = txt or get_text_from_file(file_input) 
    cleaned_txt = re.sub(r'\n\n', '\n', raw_txt)    
    write_text_to_file(cleaned_txt, file_output) # handle file_output is None in this other function
    return cleaned_txt

我的所有查询都是正确的,除了SELECT TT.RECID, TT.TRANSDATE, TT.DATAAREAID, TT.SOURCERECID, TT.SOURCEBASEAMOUNTCUR, TT.SOURCETAXAMOUNTCUR, TTGJAERIVA.TAXTRANSRELATIONSHIP, TTGJAERIVA.GENERALJOURNALACCOUNTENTRY, TTGJAERIVA.LEDGERDIMENSION, GJAERIVA.TEXT, GJAERIVA.LEDGERDIMENSION AS LEDGERDIMENSIONGAE, GJAERIVA.POSTINGTYPE FROM TAXTRANS TT INNER MERGE JOIN TAXTRANSGENERALJOURNALACCOUNTENTRY TTGJAERIVA ON TTGJAERIVA.TAXTRANS = TT.RECID INNER MERGE JOIN GENERALJOURNALACCOUNTENTRY GJAERIVA ON TTGJAERIVA.GENERALJOURNALACCOUNTENTRY = GJAERIVA.RECID AND GJAERIVA.POSTINGTYPE IN( 14,236,71,41) WHERE (TT.TAXORIGIN <> 11 AND TT.TRANSDATE BETWEEN '2016-06-30' AND '2017-06-30') OR (TT.TAXORIGIN = 11 AND TT.TRANSDATE BETWEEN '2017-06-01' AND '2017-06-30' ) 子句,如何使用Query AOT应用where子句?

在这个article中,他们适用于where子句,但他们没有解释他们是如何做到的。

当前查询

enter image description here

  

注意:如果我的问题出了问题,请告诉我   是吗。此致

1 个答案:

答案 0 :(得分:1)

您需要向数据源TaxTrans_1添加新范围 - 您可以使用字段RecId,这无关紧要。然后,您可以在此范围内使用以下值:

((TaxOrigin != 11) && (TransDate >= 30\06\2016) && (TransDate <= 30\06\2017)) || ((TaxOrigin == 11) && (TransDate >= 02\06\2017) && (TransDate <= 30\06\2017))

有关详细信息和示例,请参阅Axaptapedia