Solved

Column to show as %

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL trigger 5 23
Solar Winds can't see SQL Server Express 17 33
sql server query 12 26
Help With SQL Query 9 33
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

830 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