Solved

Column to show as %

Posted on 2014-01-16
3
241 Views
Last Modified: 2014-01-16
I have the following code
 
select dbo.test.GISHEXID,cast((dbo.test.Total_HH)as float)/cast((dbo. V_Master_Hex.Total_Households)as float) as Served_Percent,

Open in new window

.

I was hoping to show this column results as a percentage for my boss.
am I missing something? everything comes out as 4.0455555 this iwould like to see as 24% .
Thanks
0
Comment
Question by:PtboGiser
3 Comments
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 500 total points
ID: 39785828
Looks like the values might be upside down in the divide:

select dbo.test.GISHEXID,(cast(dbo.V_Master_Hex.Total_Households as float) * 100)/cast(dbo.test.Total_HH as float) as Served_Percent
0
 
LVL 2

Expert Comment

by:BarryMcGillin
ID: 39785842
Assuming the math is correct and the value for the total households is greater than the test number of house holds you should get a 0.0 to 1.0 number which you can make a percentage.
For rough percentages you dont need the cast either, which will leave you with integer values 1..100
0
 

Author Closing Comment

by:PtboGiser
ID: 39785867
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now