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.

max(timestamp) を取得するための私の 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 
  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 に答える
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 に答える