Skip to content
Advertisement

Teradata SQL returning previous two months, based on CURRENT_DATE

TLDR: I want to get a table with the previous two months in Teradata, based on CURRENT_DATE. Currently I can only get the previous month:

 is

Expected output is:


Long version: I want something, that could be used in a bigger query like this, valid for every day of the year, without hardcoding the dates. The bigger query with the hardcoded dates looks like this:

and it works perfectly. The below one returns results ok, but only for 1 month.

Tried to add a comma and add the same line with -2, did not work:

the error is:

SELECT Failed 3706: Syntax error: expected something between ‘)’ and ‘.’.

Advertisement

Answer

Why not use an or

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement