SQL code
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: SQL code

Hybrid View

  1. #1
    Join Date
    Apr 2002
    Posts
    61

    Question

    Hi all,
    I have the following data.

    Table X

    no name runtime

    15 xyz 12:20:10
    14 xya 12:20:10
    13 xyb 12:20:10
    12 xyc 12:20:10
    11 xyd 12:20:10
    10 xye 12:20:10
    9 xyf 12:10:05
    8 xyg 12:10:05
    7 xyh 12:10:05
    6 xyz 12:20:00
    5 xya 12:20:00
    4 xyb 12:20:00
    3 xyc 12:20:00
    2 xyd 12:20:00
    2 xye 12:20:00


    I need to build a view on this data and select only the latest rows that have run last at the same time runtime. I would NOT know the run when I run the statement. In the above, the result should have rows from no=15 thru no=10 (runtime 12:20:10).

    I suppose I could do the following way:

    select * from X
    where runtime=(select runtime from X where rownum<2 order by runtime desc);

    Any suggestion please.

    Thanks,
    Ramesh

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    select * from x where runtime=
    (select max(runtime) from x);
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Apr 2002
    Posts
    61

    Thanks

    Thanks Jurij

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width