select * from TNAME where
to_char (tran_date,'YYYY') = 2018
提取一天?你的代码建议年份,所以 - 我将使用一年。以下是一些选项:
SQL> select count(*) from dual where extract(year from sysdate) = 2018;
COUNT(*)
----------
1
SQL> select count(*) from dual where to_char(sysdate, 'yyyy') = '2018';
COUNT(*)
----------
1
SQL> select count(*) from dual where trunc(sysdate, 'yyyy') = date '2018-01-01';
COUNT(*)
----------
1
SQL>