select rownum message_id,send_to_p,titles,to_char(send_time,'yyyy-mm-dd hh24:mi') from (select message_id,send_to_p,titles,to_char(send_time,'yyyy-mm-dd hh24:mi') from t4012 where send_from='xxx' order by send_time desc)我在这里查询日期格式的字段,怎么报send_time标识无效了?????把send_time去掉就可以查询出来
from (select message_id,send_to_p,titles,to_char(send_time,'yyyy-mm-dd hh24:mi') as send_time
from t4012 where send_from='xxx' order by send_time desc) t
to_char(send_time,'yyyy-mm-dd hh24:mi')
from (
select message_id,send_to_p,titles,
to_char(send_time,'yyyy-mm-dd hh24:mi')
from t4012
where send_from='xxx'
order by send_time desc
)
改为:
select rownum message_id,send_to_p,titles,
send_time --使用子查询里的别名字段,已经转换过了,不用再转换,to_char(send_time,'yyyy-mm-dd hh24:mi')
from (
select message_id,send_to_p,titles,
to_char(send_time,'yyyy-mm-dd hh24:mi') as send_time --这里要定义别名
from t4012
where send_from='xxx'
order by send_time desc
)
取别名select rownum message_id,send_to_p,titles,to_char(send_time,'yyyy-mm-dd hh24:mi') from (select message_id,send_to_p,titles,to_char(send_time,'yyyy-mm-dd hh24:mi') send_time from t4012 where send_from='xxx' order by send_time desc)
SELECT ROW_NUMBER() OVER(ORDER BY SEND_TIME DESC) MESSAGE_ID,
SEND_TO_P,
TITLES,
--TO_CHAR(SEND_TIME, 'yyyy-mm-dd hh24:mi') 这个干嘛转来做什么的?
SEND_TIME
FROM T4012
WHERE SEND_FROM = 'xxx'