?
Solved

Column to show as %

Posted on 2014-01-16
3
Medium Priority
?
255 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
[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
3 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

718 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