Looking for a better query algorithm

  • I have a table that contains dates and payment amounts for users (several hundred per user). I am trying to select the record with the newest date for each user. Individual queries per user is taking for ever, so I tried to get the whole dataset this way:

    select usr,dt from test a

    where dt =

    (select max(dt) from test b where a.usr=b.usr)

    But this also seems to be taking far to long (I have about 250,000 users). Anybody have any thoughts on a better algorithm for getting this data? I don't have the ability to change the table easily (3rd party), so adding an index would be difficult.

  • select usr, max(dt) from test

    group by usr







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply