mercredi 25 novembre 2015

SQLite Selecting Average By Day While Excluding Some Hours

I have some code that selects the average by day of a list like this:

2015-11-09 09:45:34.038000 | 10
2015-11-09 10:00:34.039000 | 5

So, if those were the only two entries 11-09 would be 7.5. My SQLite query works, but I have another wrinkle, I would like to add. Here is what I have so far:

queryCurs.execute('''select strftime('%m-%d-%Y', date), round(Avg(number),2) from tableA join tableB on tableB.name = tableA.name   where place like ? group by strftime('%m-%d-%Y', date)''', (list[i],))

And this works really well. However, I would like to only include the entries that occur between 8a and 8p. How would I go about excluding anything that does fall in that range into my average?

Aucun commentaire:

Enregistrer un commentaire