Rick Ratchford wrote:
> Okay, this worked, but I have NO IDEA why.
>
>    SQLString = "SELECT min(Year) FROM TmpTable " & _
>                "WHERE Month=1 UNION " & _
>                "SELECT max(Year) FROM TmpTable " & _
>                "WHERE Month = 12 LIMIT 2"

Read about aggregate functions (min() is one of those) in your favorite 
SQL textbook, then drop the LIMIT clause. You may also want to use UNION 
ALL instead of UNION: otherwise, if you just have one full year's worth 
of data, you'll get a single row as UNION removes duplicates.

In fact, it may be more convenient (definitely easier to reuse as a 
fragment in more complicated queries) to return this result as one row 
with two columns:

select
    (select min(Year) ...) as firstFullYear,
    (select max(Year) ...) as lastFullYear;

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to