Solved

Dividing one int type column by another int column and returning a numeric value for a list

Posted on 2012-03-14
1
312 Views
Last Modified: 2012-03-14
How is the best way to divide an int column by another int column and returning a numeric value for a set of records (one operation per row) such as

select col1, col2, col2/col1 * 100 as col3
0
Comment
Question by:kenv611
1 Comment
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37722382
that is fine . . . if you're looking for a % then just cast them as numbers:

select col1, col2, cast (col2 as number(18,2)) / cast (col1 as number(18,2)) * 100 as col3
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linked Server Issue with SQL2012 3 26
TSQL - How to declare table name 26 31
How to search for strings inside db views 4 28
Merge two rows in SQL 4 17
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

831 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