Linear regression

How to calculate linear regression in oracle plsql.
Please see the file attached.
C--Tanuja-Lake_IL-BRDs-linear-regre.docx
Tanuja KadamProgrmmer AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
Do you have the excel file or the raw data instead of a picture of data?

In any case,  you shouldn't use PL/SQL to solve this.  Instead use the built in SQL aggregate function REGR_SLOPE.
 

SELECT REGR_SLOPE(dependent_variables, independent_variables)  FROM yourtable

if you're trying to do it "manually" then you can use the basic SUM and COUNT aggregate functions.  This does assume every (dep,indep) pair is not null for both elements, which is true for your sample data.

select  ((SUM(dep * indep) - SUM(indep) * SUM(dep) / COUNT(*)) / COUNT(*))  / ((SUM(POWER(indep, 2)) - POWER(SUM(indep), 2) / COUNT(*)) / COUNT(*)) from yourtable
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tanuja KadamProgrmmer AnalystAuthor Commented:
Thank you.
I will use this function and let you know.
0
Tanuja KadamProgrmmer AnalystAuthor Commented:
I also Need to calculate sales ratio. I have the details attached. Really appreciate your help and time.
C--Tanuja-Lake_IL-BRDs-sales-ratio-.docx
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

sdstuberCommented:
please open a new question for a new question.

in your new question please provide sample data and expected results.

Please provide the data in a form that can be imported to create a test case.
0
Tanuja KadamProgrmmer AnalystAuthor Commented:
I have opened a new question. Thanks
0
Tanuja KadamProgrmmer AnalystAuthor Commented:
Appreciate your help. The solution work perfectly.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Statistical Packages

From novice to tech pro — start learning today.