展示三年多前出版的书籍的详细资料,销量不到10000册。
我的老师要求修改这个
Select title_id , title , pubdate , current_date-pubdate, ytd_sales
from titles;这就是我所做的
Select title_id , title , pubdate , current_date-pubdate, ytd_sales
from titles
where ytd_sales > 10 000;但问题来了,我不能使用DATEADD,我意识到我的老师把current_date - pubdate,我想他想使用其他方法,但我不知道。
如果使用DATEADD,它就会出来
ORA-00904:"DATEADD":无效标识符
发布于 2015-06-21 13:50:14
你能在以下几个方面:
alter SESSION set NLS_DATE_FORMAT = 'MM-DD-YYYY HH24:MI:SS' ;
--select * from nls_session_parameters where parameter = 'NLS_DATE_FORMAT';
create table TITLES( title_id number(10), title varchar2(20), pubdate date, ytd_sales number(10));
insert into TITLES values(101,'ABC',TO_DATE('07-13-2011','MM-DD-YYYY'),20000);
insert into TITLES values(102,'DEF',TO_DATE('07-13-2014','MM-DD-YYYY'),90000);
commit;
Select title_id , title , pubdate , round( (trunc(sysdate)-pubdate) /365) years, ytd_sales
from TITLES
where ytd_sales > 10000
and round( (trunc(sysdate)-pubdate) /365) > 3 --this will check for the pub date > 3 years
;产出:

发布于 2015-06-21 13:18:57
我想大概是这样的。
Select title_id , title , pubdate , current_date-pubdate, ytd_sales
from titles
where ytd_sales > 10 000;
AND pubdate < add_months(sysdate, -36)https://stackoverflow.com/questions/30964764
复制相似问题