如何在Teradata中计算以下内容:
Beginning Of Previous Month,
End Of Previous Month,
Beginning Of Six Months Ago,
Beginning Of Twelve Months Ago
感谢。
答案 0 :(得分:1)
Beginning Of Previous Month: add_months(current_date - (extract(day from current_date)-1), -1)
End Of Previous Month: current_date - (extract(day from current_date))
Beginning Of Six Months Ago: add_months(current_date - (extract(day from current_date)-1), -6)
Beginning Of Twelve Months Ago: add_months(current_date - (extract(day from current_date)-1), -12)
根据您的版本,可能会有一些功能:
td_month_begin(add_months(current_date,-1))
last_day(add_months(current_date,-1))
或者,如果这些列已存在,您可以检查(希望)现有的日历表。