I'm trying to correctly word an SQL statement.

Data Fields:  ID, Date, Month, Day, Year, Price

Problem: When provided the starting Month/Day numbers, and ending Month/Day
numbers, what is the correct way to SQL the database so that the recordset
created returns as follows (assume 4 years of data):

Example:

Starting Month = 3
Starting Day = 12

Ending Month = 7
Ending Day = 5

The recordset created needs to return the data in these columns:

Month   Day   Price
===============
3          12      24.50
3          12      12.34
3          12      33.01
3          12       8.76
3          13      11.72
3          13      77.55
3          13      12.00
.
.
7           5       99.87
7           5        6.22
7           5       54.61


In other words, all the 3/12's first, then 3/13's, then 3/14's, etc. all the
way down to the ending Month/Date.

Where I really get stuck is when the Starting Month number is greater than
the Ending Month number. For example, say I want the starting Month/Day as
10/22 and the ending Month/Day as 4/16. Simply stating WHERE Month >= Start
Month AND Month <= End Month doesn't seem correct. Since I want to return
all the prices between 10/22 and 4/16 of each year of data I have in the
table, no Month number could be greater than/equal to 10  and also less
than/equal to 4.

I'm still pretty green on working out these SQL statements. I'm hoping some
suggestions will help.

Thanks.

Rick



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

Reply via email to