Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Slope

Posted on 2006-11-30
Medium Priority
458 Views
Hello,

I am trying to find the linear regression of weight gain over time via MS SQL Server.  I found a function for slope and im trying to apply it.  I am looking for a conformation on this equation and if im applying it correctly.

Slope = ( COUNT(*)*SUM(x*y) -SUM(x)*SUM(y) ) / (COUNT(*)*SUM(x^2)-SUM(x)^2)

The site i found it said x is date and y is weight.  I figured (correct me if im wrong) that x would be the age of the bird in days so i came up with the following query....

SELECT
(COUNT(*)*SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float)*Weight) -SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float))*SUM(Weight) ) / (COUNT(*)*SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float)^2)-SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float))^2)
FROM
WingbandFlock As wf
INNER JOIN
Weight As w
ON
wf.[Bird ID] = w.[Bird ID]

In concept, am i correct?  I am still running into an SQL error i have not solved, if you know that you can post the answer in my related question for more points :)

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_22077814.html#a18045854

Thanks!

-Navicerts
0
Question by:Navicerts
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 84

Accepted Solution

ozo earned 2000 total points
ID: 18046653
I thought ^ in SQL meant xor, not power
0

LVL 7

Author Comment

ID: 18047075
Well shoot, that explains some things.  Working now!  Sorry i *thought* it was a math question, but you answered an SQL Server question :)  I graphed it and the answer checks out too.

Thanks again!

SELECT
(Count(*)*SUM(Cast([Feed Consumed] As float)*([Weight Gain]*453.6)) -SUM(Cast([Feed Consumed] As float))*SUM(([Weight Gain]*453.6)) ) / (Count(*)*SUM(power(Cast([Feed Consumed] As float),2))-power(SUM(Cast([Feed Consumed] As float)), 2))
FROM
WingbandFlock As wf
INNER JOIN
[Feed Consumed] As fc
ON
wf.[Bird ID] = fc.[Bird ID]
INNER JOIN
[Keepers Report] As kr
ON
wf.[Bird ID] = kr.[Bird ID]
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
###### Suggested Courses
Course of the Month11 days, 10 hours left to enroll