[Resolved] GC6JHC6 - Pattern matching on the year grid May 31, 2016 01:30AM |
Registered: 7 years ago Posts: 53 |
select a,b,sum(f) n from (select a,b,m,d,(case when (select count(*) from caches where strftime('%m/%d',foundbymedate)=y.m||'/'||y.d)>1 then 1 else 0 end) f from (with recursive ab(a,b,n) as (values(0,0,1) union all select (n/22), (n%22), n+1 from ab where n<44) select a,b from ab) x join (with recursive yd(m,d,n) as (values('01','01',1) union all select strftime('%m',2451544.5+n),strftime('%d',2451544.5+n),n+1 from yd where n<366) select m,d from yd) y where m||'/'||d in (with X(m,d) as (values (0,2),(0,3),(1,2),(1,3),(2,3),(2,4),(2,5),(2,6),(3,0),(3,2),(3,3),(3,4),(3,7),(4,0),(4,1),(4,4),(4,7),(5,4),(5,5),(6,3),(6,4),(6,5),(7,2),(7,5),(7,6),(7,8),(8,2),(8,3),(8,6),(8,7),(8,9),(9,4),(10,3),(10,4)) select strftime('%m/%d',date('2000-01-01','+'||(m+a)||' months','+'||(d+b)||' days')) from X)) group by a,b order by n desc, a,bNote the above origin range for this example is hard-coded, only because at this point the sqlite date check uses an offset, so for example Feb 1 + 30 days would end up in March instead of an invalid date, so I had to define valid origin ranges incorporating only valid dates. That shouldn't be a hard fix inside a more flexible script than a single SQL query :)
Re: GC6JHC6 - Pattern matching on the year grid May 31, 2016 05:02AM |
Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid May 31, 2016 07:00AM |
Moderator Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid May 31, 2016 03:47PM |
Registered: 7 years ago Posts: 53 |
Re: GC6JHC6 - Pattern matching on the year grid June 06, 2016 01:31AM |
Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid June 06, 2016 03:09PM |
Registered: 7 years ago Posts: 53 |
Re: GC6JHC6 - Pattern matching on the year grid June 06, 2016 03:14PM |
Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid June 01, 2016 02:06AM |
Moderator Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid June 01, 2016 05:30AM |
Moderator Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid June 01, 2016 05:27PM |
Registered: 7 years ago Posts: 53 |
Re: GC6JHC6 - Pattern matching on the year grid June 02, 2016 03:55AM |
Moderator Registered: 7 years ago Posts: 1,848 |
Re: GC6JHC6 - Pattern matching on the year grid June 02, 2016 04:59PM |
Registered: 7 years ago Posts: 53 |
Re: GC6JHC6 - Pattern matching on the year grid June 02, 2016 05:14PM |
Moderator Registered: 7 years ago Posts: 659 |