How to insert a coulmn in Excel that is resulted from calculated columns in sql database

I am importing table data from SQl database in Excel by query.. however, I would like to insert additional columns in excel which are resulted from a formula done to already existing columns in the database. For instance, in SQL database I have Campaign table that consist of (AccountID, Campaign, Cost, Clicks and impressions) these columns are imported successfully to Excel. I would like to add to Excel table another column (CTR) which is equals (Clicks/impressions)
is there any way that allow me to do that?

Thank you
Rawan JambiAsked:
Who is Participating?
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.

RayData AnalystCommented:
You can do it one of two ways.  The easiest, add an item to the select query that like
      ,clicks/impressions as 'CTR'
That will put the results in with the query results.  

Option B, if you're using a query table within the excel, is to simply add a formula to the column next to the last column of your query results.  This link gives a pretty good detail on doing that so I won't 'reinvent the wheel here'.
http://www.agentjim.com/mvp/excel/2011Relational22Queries.html
0

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
Vikas GargBusiness Intelligence DeveloperCommented:
Hi,

You can add extra column to sql

insert into OPENROWSET('Microsoft.Ace.OLEDB.12.0','Excel 12.0;Database=D:\testing.xlsx;', 
    'SELECT * FROM [Sheet2$]') select *,yourcolumn  as CTR from Comb

Open in new window

0
Don ThomsonCommented:
What version of Excel are you working with?
I personally would import the SQL data into Access - then run a query to add the formula and create a new table (or modify the existing table)  and then if you need to, export it to an Excel format.

You could of course just do it directly in Excel using a Macro (activated with either a keystroke or via a button)
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
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.