I'm writing a SQL query which calculates the average daily water usage for a utility company.
Usage reads come to us in the following format:
ReadBegin (start date of meter reading)
ReadEnd (end date of meter reading)
Volume (in Liters)
The meter reads have a ReadBegin and ReadEnd typically crossing month boundaries, for example, 3/31/2007 and 4/13/2007. Most months there is only a single read for the month, but occasionally there are two.
My question, say you have these reads in a given month:
3/1/2007 - 3/31/2007, average daily usage 100.10 L
3/31/2007 - 4/13/2007, average daily usage 39.4 L
What would be the proper way to factor in the average daily usage for 3/31, since here there are essentially two meter reads (and therefore two ranges used to calculate averages) used?
I was thinking that for March 1 - 30, I would use 100.10 (the ADU for the first read), and for March 31 I would use the average of the two averages, 100.10 + 39.4 / 2.
2007-12-14
03:20:14
·
3 answers
·
asked by
Anonymous