Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2011, 12:45 PM
Authorized User
 
Join Date: Sep 2009
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default Linear functions in SQL 2008

Hello,

Anyone having idea about the linear regression functions in SQL 2008 like LINEST in EXCEL? Or any function for SLOPE & INTERCEPT? Or any function created for this will be helpful.

Thanks in advance for any help.

Regards,
Narendra
 
Old April 7th, 2011, 01:07 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I think these are not available in SQL server
Please check the following for some of the options:
http://knol.google.com/k/linus-nilss.../g1yluc4toyn/8
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following 2 Users Say Thank You to om_prakash For This Useful Post:
Narendra.Patil (April 7th, 2011)
 
Old April 7th, 2011, 03:04 AM
Authorized User
 
Join Date: Sep 2009
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Thanks Om,

I also got some info on net. Need to create SQL UDF.


set nocount on
declare @n int
create table #lr (x real not null, y real not null)
--insert sample data
insert into #lr values (2005,5.620400866)
insert into #lr values (2006,5.638354669)
insert into #lr values (2007,5.659482216)
insert into #lr values (2008,5.676753802)
insert into #lr values (2009,5.697093487)
select @n=count(*) from #lr --this is just for convenience, you can substitute count(*) for @n in the code
--meat of the code begins here
select
((@n * sum(x*y)) - (sum(x)*sum(y)))/
((@n * sum(Power(x,2)))-Power(Sum(x),2)) AS Slope,
avg(y) - ((@n * sum(x*y)) - (sum(x)*sum(y)))/
((@n * sum(Power(x,2)))-Power(Sum(x),2)) * avg(x) as Intercept
from #lr
drop table #lr
 
Old April 7th, 2011, 03:19 AM
saymamohib28
Guest
 
Posts: n/a
Default erp definiton

erp definiton





Similar Threads
Thread Thread Starter Forum Replies Last Post
Synchronization between SQL 2008 Express on local machine and SQL hosting server avidan ASP.NET 4 General Discussion 0 December 29th, 2010 12:31 PM
Has anyone got this working with VWDE 2008 / SQL Express 2008? john77 BOOK: ASP.NET 3.5 Website Programming Problem Design Solution 4 January 18th, 2010 01:16 PM
SQL 2008 will not run on Windows 2008? dkrus Book: Professional Microsoft SQL Server 2008 Administration ISBN: 978-0-470-24796-9 1 February 23rd, 2009 12:34 PM
Solve Linear Equation in XSLT waqasnet XSLT 2 November 10th, 2008 02:34 PM
Linear programming problem milk_vanilla Excel VBA 5 August 25th, 2005 09:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.