Solved

Column to show as %

Posted on 2014-01-16
3
251 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

738 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