rixtertrader <[email protected]> wrote:
> Igor Tandetnik wrote:
>> GROUP BY Year + (WeekNum=53), WeekNum - (WeekNum=53)*52
>>
>> This should effectively merge week 53 with week 1 of next year.
>
> I don't understand how it works.
It's simple, really. (WeekNum=53) is a boolean expression, which has a value of
1 (for true) or 0 (for false). So Year + (WeekNum=53) is equal to Year most of
the time, but Year + 1 when WeekNum is 53. Similarly WeekNum - (WeekNum=53)*52
is equal to WeekNum most of the time, but to 1 (53 - 1 * 52) when WeekNum is 53.
It could be written more explicitly:
GROUP BY Year + (case WeekNum when 53 then 1 else 0 end),
(case WeekNum when 53 then 1 else WeekNum end);
Perhaps I was being too clever.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users