Author |
Topic |
Kristen
Test
22859 Posts |
Posted - 2007-08-02 : 06:16:12
|
I need some help with some maths please for a mate.He sells solar panels. He wants to show how much energy has been saved by his customers.So ... he sells 2 systems per day and they each save 10 kWh per day.So on day one the saving is 10 kWhOn day 2 he has sold another 2 units, so the saving that day is 20 kWh - plus the 10 kWh from the day beforeOn day 3 he has sold another 2 units, the saving that day is 30 kWh plus the 30 kWh to day.What's the formula saving for day N please?(Actually what is needed is for a calculation that starts on D-Day with a total of, say, 123 units have been sold-to-date and a total saving-to-date of, say, 5678 kWh. So the calculation needs to run from D-Day+1, taking into account the save-to-D-day kWh and units sold)(This is actually going to be a JavaScript solution, so doesn't need to use SQL maths stuff necessarily!)Kristen |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-02 : 06:51:56
|
I think this is the way to count Day1 Day2 Day3 SavingsHouse 1 20 20 20 60House 2 20 20 40House 3 20 20 20 40 60 120 10kWh * units * days * (days + 1) / 2 E 12°55'05.25"N 56°04'39.16" |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-02 : 08:08:21
|
this is not the place for homework questions. If we do it for you, you'll learn nothingHereafter please avoid this. _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-02 : 08:09:17
|
how can he be saving 10KWh on day 1??_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
pootle_flump
1064 Posts |
Posted - 2007-08-02 : 08:32:33
|
quote: Originally posted by spirit1 this is not the place for homework questions. If we do it for you, you'll learn nothing
Yup. And dodgy sample data\ expected output too. As MVJ says - if you can't formulate the question you have no chance of working out the answer for yourself. |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-08-02 : 08:48:08
|
Peso: That looks like a runner, thanks."As MVJ says - if you can't formulate the question you have no chance of working out the answer for yourself."And he hasn't even entered the thread yet - LOL!"how can he be saving 10KWh on day 1??"Buy at midnight, its a 1 second install ... The accuracy is not too important, and the day-1-start / day-2-start inaccuracy will not really be relevant. The guy wants a running counter on his website to show how much energy sales by his company has saved in total.The maths is beyond me, but I'm doing it for free so I don't feel bad about getting you guys to help for free either. AND I don't get the chance to graduate at the end of this, so you can stuff all your pompous proposals. Hmm ... I like that ... hereafter to be known as "PP's" ... Kristen |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-02 : 08:55:43
|
Do you wish to start a PP list? Please click Yes or No now. E 12°55'05.25"N 56°04'39.16" |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-08-02 : 10:56:16
|
quote: Originally posted by pootle_flump...As MVJ says - if you can't formulate the question you have no chance of working out the answer for yourself...
When did I say that?It sounds too courteous to be something I said, but maybe I was having an off day.declare @t table (SaleID int not null identity(1,1) primary key clustered,Install_Date datetime not null)insert into @tselect Install_Date = '20070730' union allselect Install_Date = '20070731' union allselect Install_Date = '20070731' union allselect Install_Date = '20070801' union allselect Install_Date = '20070801'order by 1select a.*, Days_Since_Install = datediff(day,a.Install_Date,b.Today), Total_KWHours_Saved = 10 * datediff(day,a.Install_Date,b.Today)from @t a cross join ( Select Today = dateadd(day,datediff(day,0,getdate()),0) ) border by a.SaleIDResults:(5 row(s) affected)SaleID Install_Date Days_Since_Install Total_KWHours_Saved ----------- ------------------------------------------------------ ------------------ ------------------- 1 2007-07-30 00:00:00.000 3 302 2007-07-31 00:00:00.000 2 203 2007-07-31 00:00:00.000 2 204 2007-08-01 00:00:00.000 1 105 2007-08-01 00:00:00.000 1 10(5 row(s) affected) CODO ERGO SUM |
 |
|
pootle_flump
1064 Posts |
Posted - 2007-08-02 : 11:26:10
|
quote: Originally posted by Michael Valentine Jones
quote: Originally posted by pootle_flump...As MVJ says - if you can't formulate the question you have no chance of working out the answer for yourself...
When did I say that?It sounds too courteous to be something I said, but maybe I was having an off day.
I paraphrased you. My memory is a little hazy but I think your original proposal involved ridiculing the OP in front of their peers and then shooting them as an example to everyone else. Something along those lines anyway.EDIT - cocked up the quotey bit |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-08-02 : 12:16:46
|
"but I think your original proposal involved .."Definitely a PP then, eh? !! |
 |
|
pootle_flump
1064 Posts |
Posted - 2007-08-03 : 02:59:12
|
quote: Originally posted by Kristen "but I think your original proposal involved .."Definitely a PP then, eh? !!
heh heh - oh yes I missed that! |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-15 : 19:05:11
|
Did he implement the counter? What is the URL? E 12°55'05.25"N 56°04'39.16" |
 |
|
pootle_flump
1064 Posts |
Posted - 2007-08-15 : 19:42:12
|
Heh - looking at your recent acivity Peter it looks like you have found some time to tie up loose ends |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-16 : 16:21:55
|
Yes, my daughter and girlfriend are both sleeping now. E 12°55'05.25"N 56°04'39.16" |
 |
|
|