Rick Ratchford wrote: > For example, say that I want to run this SQL statement to pull out SETS that > start with a MM/DD of 12/28 to 01/05. That means, each 'set' would be from > December 25 to January 05, which means that each 'set' will cross a year end > date (where the year value increments by 1). > > While the above SQL statement will do this, to a point, the first set is > usually not correct. It will look like this: > > Date | Year | Month | Day > > 12/28/1988 1988 12 28 > 12/29/1988 1988 12 29 > 12/30/1988 1988 12 30 > 01/04/1988 1988 01 04 > 01/05/1988 1988 01 05 > 12/28/1989 1989 12 28 > 12/29/1989 1989 12 29 > 01/03/1989 1989 01 03 > 01/04/1989 1989 01 04 > 01/05/1989 1989 01 05 > > As you can see, the first set has a problem It goes from December 28, 1988 > to January 05, 1988, rather than January 05, 1989 like it should for the > first SET.
Actually, it only seems this way due to the sorting order. If you just do "ORDER BY Year, Month, Day" you'll see what's going on. You have one set going from 12/28/87 to 01/05/88 (which just happens to be incomplete as you have no records in 1987), and another unrelated set going from 12/28/88 to 01/05/89. Your overcomplicated ORDER BY clause causes these two sets to interleave. > I fugure the way to correct this issue is to make sure that each ROW > (record) has a DATE that is greater than the last ROW. So, just say that in ORDER BY. > Is it possible to have the SQL statement above do this as well? Yes. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users