in reply to Re^3: SQl logic inPerl
in thread SQl logic inPerl

I can try to explain the possibilities; if I have two records into this database table one from 2009 and the other from 2010, the query in question will bring both and not just one of the records, like it is the intention on the SQL query I am trying to do. I just need to get 2009 if it is there, if not then go get me 2010 record.

Replies are listed 'Best First'.
Re^5: SQl logic inPerl
by Corion (Patriarch) on Jul 14, 2010 at 19:53 UTC

    So, you want to always take the first row, if you order by year ascending? Why don't you just do that?

    select ... order by year asc limit 1

    or, depending on your brand of database

    select top 1 ... order by year asc