Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 The Yak Corral
 Maths help - Exponential stuff

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 kWh
On day 2 he has sold another 2 units, so the saving that day is 20 kWh - plus the 10 kWh from the day before
On 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	Savings
House 1 20 20 20 60
House 2 20 20 40
House 3 20 20
20 40 60 120

10kWh * units * days * (days + 1) / 2


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

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 nothing

Hereafter please avoid this.



_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

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 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

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.
Go to Top of Page

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
Go to Top of Page

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"
Go to Top of Page

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 @t
select Install_Date = '20070730' union all
select Install_Date = '20070731' union all
select Install_Date = '20070731' union all
select Install_Date = '20070801' union all
select Install_Date = '20070801'
order by 1

select
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) ) b
order by
a.SaleID


Results:


(5 row(s) affected)

SaleID Install_Date Days_Since_Install Total_KWHours_Saved
----------- ------------------------------------------------------ ------------------ -------------------
1 2007-07-30 00:00:00.000 3 30
2 2007-07-31 00:00:00.000 2 20
3 2007-07-31 00:00:00.000 2 20
4 2007-08-01 00:00:00.000 1 10
5 2007-08-01 00:00:00.000 1 10

(5 row(s) affected)




CODO ERGO SUM
Go to Top of Page

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
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-08-02 : 12:16:46
"but I think your original proposal involved .."

Definitely a PP then, eh? !!
Go to Top of Page

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!
Go to Top of Page

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"
Go to Top of Page

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
Go to Top of Page

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"
Go to Top of Page
   

- Advertisement -