[sqlite] Summing values by date, returning 0 for missing dates

2016-05-18 Thread R Smith
On 2016/05/18 12:26 AM, Jonathan wrote: > Hi Ryan, > Thanks for the excellent and comprehensive answer; it seems like CTE's > are the way to go for this. > I did a quick google and this tutorial was very helpful (for anyone > else newly interested in CTE's - >

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-18 Thread Jonathan
Hi Ryan, Thanks for the excellent and comprehensive answer; it seems like CTE's are the way to go for this. I did a quick google and this tutorial was very helpful (for anyone else newly interested in CTE's -

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-14 Thread R Smith
On 2016/05/13 4:56 PM, Jonathan Moules wrote: > Hi Simon, >Sorry, maybe we're crossing wires, but I'm not sure to what you're > referring. How is defining the type as DATE impeding my attempt to get a > value of 0 for non-existent rows? > Ryan's response with a CTE seems to probably be

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-13 Thread Simon Slavin
On 13 May 2016, at 3:56pm, Jonathan Moules wrote: > Sorry, maybe we're crossing wires, but I'm not sure to what you're > referring. How is defining the type as DATE impeding my attempt to get a > value of 0 for non-existent rows? > Ryan's response with a CTE seems to probably be what I want

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-13 Thread Jonathan Moules
Hi Simon, Sorry, maybe we're crossing wires, but I'm not sure to what you're referring. How is defining the type as DATE impeding my attempt to get a value of 0 for non-existent rows? Ryan's response with a CTE seems to probably be what I want (not had the opportunity to test it yet - CTE's

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-12 Thread Simon Slavin
On 12 May 2016, at 3:55pm, Jonathan Moules wrote: > I know that the "DATE" type isn't actually a type in SQLite and that there > are no date-specific constraints, but I find it a convenient indicator (to me > and potentially anyone else who's going to see the code) as to the type of >

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-12 Thread Jonathan Moules
Hi Simon, I know that the "DATE" type isn't actually a type in SQLite and that there are no date-specific constraints, but I find it a convenient indicator (to me and potentially anyone else who's going to see the code) as to the type of data that is to be held in that column. I figured

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-12 Thread R Smith
I should add... The initial CTE setting up minDT and maxDT can be ANY dates, it doesn't have to come from the MIN/MAX in my_table, for example: WITH dtRange(minDT,maxDT) AS ( SELECT '2015-12-30 00:00:00', datetime(date('now','localtime','-3 months')) -- 30 December 2015 to today 3

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-12 Thread R Smith
On 2016/05/12 12:20 AM, Jonathan wrote: > Hi List, > Let's say I have a table with a simplified structure like this: > /create table my_table(// > //time_date DATE,// > //num INTEGER// > //);/ > > My data has three rows and looks like this: > /2016-01-01; 3//

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-12 Thread Simon Slavin
On 11 May 2016, at 11:20pm, Jonathan wrote: > //time_date DATE,// SQLite has no DATE type. Put your data in that table and try this command: SELECT time_date,typeof(time_date) FROM my_table Then try it again, this time defining that column as TEXT. Simon.

[sqlite] Summing values by date, returning 0 for missing dates

2016-05-12 Thread Jonathan
Hi List, Let's say I have a table with a simplified structure like this: /create table my_table(// //time_date DATE,// //num INTEGER// //);/ My data has three rows and looks like this: /2016-01-01; 3// //2016-01-01; 1// //2016-01-03; 2/ I want