以下是初始SQL查询:
SELECT a.displaynamewithhierarchy as account_name,
BUILTIN.DF(a.accttype) as account_type,
t.id as internal_id,
BUILTIN.DF(t.type) as transaction_type,
t.trandate as transaction_date,
BUILTIN.DF(t.postingperiod) as period,
BUILTIN.CONSOLIDATE(tl.amount, 'INCOME', 'DEFAULT', 'DEFAULT', 1, t.postingperiod, 1) as amount,
BUILTIN.DF(t.currency) as currency,
tl.debitforeignamount as amount_debit_foreign,
tl.creditforeignamount as amount_credit_foreign
FROM transaction t
LEFT JOIN transactionline tl on t.id = tl.transaction
LEFT JOIN transactionaccountingline tal on tl.id = tal.transactionline and t.id = tal.transaction
LEFT JOIN account a on tal.account = a.id
WHERE t.tranid = 'JE2012020'
我想改变t.postingperiod
(从BUILTIN.CONSOLIDATE()函数),并使用t.trandate
的发布周期ID(该字段将是postingperiod表中的id
)。
postingperiod表如下所示:Posting Period Table
你知道如何修改查询吗?
1条答案
按热度按时间s5a0g9ez1#
看起来你只需要加入这个表,并在你想要的地方使用
SELECT
列表中的列。根据你的表结构,可能像这样连接: