Oracle SQL: Query One Year of Data

You can use the following SQL statement in Oracle database to query data within one year:

SELECT * FROM your_table
WHERE your_date_column >= TRUNC(sysdate, 'YEAR')
AND your_date_column < ADD_MONTHS(TRUNC(sysdate, 'YEAR'), 12);

In the SQL statement above, ‘your_table’ is the table name to query, and ‘your_date_column’ is the column containing date data. TRUNC(sysdate, ‘YEAR’) is used to retrieve the first day of the current year, and ADD_MONTHS(TRUNC(sysdate, ‘YEAR’), 12) is used to retrieve the last day of the current year. With this SQL statement, one can query data from within a year.

bannerAds