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

So, what is the issue? Is the issue that you get two lines? Maybe you want to get the first line, when you ORDER BY some criterion? You haven't shown any example output and what result you prefer over what other result, so it's kinda hard to guess what you might mean.

Replies are listed 'Best First'.
Re^4: SQl logic inPerl
by Anonymous Monk on Jul 14, 2010 at 19:49 UTC
    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.

      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