On 9/07/2009 3:39 AM, Igor Tandetnik wrote:
> Rick Ratchford <r...@amazingaccuracy.com>
> wrote:
>> Can someone help me with a SQL request?
>>
>> The Table contains Date, as well as Year, Month and Day columns.
>>
>> I would like to return a recordset that is made up of only COMPLETE
>> YEARS, from January to December.
>>
>> Say my data starts on August 14, 1975 and ends with May 4, 2009.
>>
>> How do I get just those records that start from January 1, 1976 to
>> December 31, 2008, as those would be the only COMPLETE YEARS from
>> January to December in my table?
> 
> Perhaps something like this:
> 
> select * from myTable
> where Year between
>     (select min(Year) from myTable where Month=1 and Day=1)
> and
>     (select max(Year) from myTable where Month=12 and Day=31);
> 

This assumes something that wasn't explicitly stated: there is data for 
each and every day from the start date to the end date. For example, if 
there were no records for January 1977, Igor's query would still use 
1976 as the first complete year.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to