I'm stuck on a problem that is halting my project. I hope someone can help
on this one as I think it's a SQL related question.
 
MyTable contains the Date, Year, Week (and other columns).
Week is a week number.
 
MyTable holds my stock prices for each trading day.
 
I've omited the price data column references to keep this question as clear
as possible.
 
SELECT Date FROM MyTable GROUP BY Year, Week
 
This creates a recordset that groups all my prices into 'weekly' prices. In
other words, each row represents the High, Low, Close prices for each week,
and the date is the FRIDAY DATE of that week.
 
So the above statement might return the following (last 5 only):
 
...
07/03/2009
07/10/2009
07/17/2009
07/24/2009
07/31/2009
 
Note that each row in the Date column is a date that represents the last
date of the week, Friday's date.
 
What I want to do is modify this SELECT statement so that the rows returned
do not go past a certain date. Let's call it dStopDate.
 
If I have dStopDate = '2009-28-07', for example, then the last row I want to
return is 07/24/2009, which is the last week prior to my dStopDate.
 
However, by adding WHERE Date < '" dStopDate "' prior to GROUP BY... (and
yes, assume Date and dStopDate are same format), my last record returned is
actually 07/27/2009 (the day before my dStopDate) rather than my 'weekly'
record of 07/24/2009.
 
I can't put my finger on my error.
 
Anyone have a suggestion?
 
Thanks.
 
Rick
 
 
 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to