0

我这里有问题。

我想根据该列的 max(timestamp) 选择一列,但我一直在检索它。假设我有以下数据:

Comments
========
abcd 2012/08/14 8:03:03 AM more data inside <- I want to retrieve this
hshsh 2012/08/13 1:03:03 AM some other comments
hahhah 2012/08/10 8:03:03 PM test it.

我检索最大值(时间戳)的 SQL 是

select max(substr(comments, instr(comments, '2012'), instr(comments, 'M') - 6)) from TABLEA

但是如何根据此语句选择此列?

编辑:

是否有可能做到这一点:

select comments from tableA where comments like (select max(substr(comments,   instr(comments, '2012'), instr(comments, 'M') - 6)) from TABLEA)

我希望得到评论列的第一行,但没有输出。我希望我不会太含糊...我正在使用 Oracle SQL。

4

2 回答 2

0

尝试:

select *
from 
(
    select comments
    from TABLEA
    order by substr(comments, instr(comments, '2012'), instr(comments, 'M') - 6) desc
)
where rownum = 1
于 2012-08-31T08:53:33.333 回答
0

你可以试试:

  select 
  comments, substr(comments, instr(comments, '2012'), instr(comments, 'M') - 6) YEAR
  from TABLEA
  order by substr(comments, instr(comments, '2012'), instr(comments, 'M') - 6) desc
  where rownum = 1
于 2012-08-31T09:00:56.100 回答