Solved

Slope

Posted on 2006-11-30
2
455 Views
Last Modified: 2008-03-03
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
Comment
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
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 18046653
I thought ^ in SQL meant xor, not power
0
 
LVL 7

Author Comment

by:Navicerts
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction On a scale of 1 to 10, how would you rate our Product? Many of us have answered that question time and time again. But only a few of us have had the pleasure of receiving a stack of the filled out surveys and being asked to do somethi…
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question