Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3800894
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:57:51+00:00 2026-05-19T13:57:51+00:00

In SQL, I have col1 and col2 . Both are integers. I want to

  • 0

In SQL, I have col1 and col2. Both are integers.

I want to do like:

select col1/col2 from tbl1

I get the result 1 where col1=3 and col2=2

The result I want is 1.1

I put round(col1/col2,2). The result is still 1.

I put decimal(col1/col2,2). The decimal is not built in function.

How can I do exactly to get 1.1?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:57:52+00:00Added an answer on May 19, 2026 at 1:57 pm

    You will need to cast or convert the values to decimal before division. Take a look at this
    http://msdn.microsoft.com/en-us/library/aa226054.aspx

    For example

    DECLARE @num1 int = 3 DECLARE @num2 int = 2
    
    SELECT @num1/@num2
    
    SELECT @num1/CONVERT(decimal(4,2), @num2)
    

    The first SELECT will result in what you’re seeing while the second SELECT will have the correct answer 1.500000

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL query like SELECT Col1, Col2 FROM Table1 UNION ALL SELECT
I have an sql query like this Select col1, (select abc from table2 where
i have sql statement like this SELECT DISTINCT results_sp_08.material_number FROM results_sp_08 INNER JOIN courses
I have table like this col1 col2 col3 3 5 8 4 5 5
i am using microsoft access jet sql. i have table col1 and col2 i
I have a sql select query that extracts result as: login_count login_type 2000 iPhone
i have in a procedure which fills a table the following sql SELECT NVL(SUM(COL1),
I am using SQL SERVER 2005. I have a table table1(ID,col1,col2,col3,col4); Now I have
Lets say i have a table like this: col1 col2 col3 row1 1 null
I have a table that looks like this: col1 col2 col3 ------ ----- -----

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.