I've been trying all kinds of different ways to accomplish the following, and my head is spinning. Problem: How do you return from the DB just the YEAR of the first and last YEAR that had dates from 1st week of January to last week of December? Clarification: Suppose you had a database that contained stock price data. You are only interested in the first and last year that was a complete year. A "complete year" is a year where you have price data from the very first weekday (not weekend or holiday) of the year to the very last weekday of that year. Usually, a complete year is from Jan 2, 3 or 4 to Dec 29, 30, 31. Result Desired: To simply return the YEAR of the first complete year, and the YEAR of the last complete year of the dataset. This should return only two years in a single column. If 1988 is the first complete year and 2008 is the last complete year, then it should only return: 1988 2008 Available columns are: DATE (complete date) YEAR MONTH DAY ... I'm trying to do something like this, but it won't work because it says you can only have one LIMIT clause. SQLString = "SELECT min(Year) FROM TmpTable " & _ "WHERE Month=1 LIMIT 1 UNION " & _ "SELECT max(Year) FROM TmpTable " & _ "WHERE Month = 12 LIMIT 1"
Help would be appreciated. Thanks. Rick _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users