Skip to content
Fix Code Error

SQL – Rounding off to 2 decimal places

March 13, 2021 by Code Error
Posted By: Anonymous

I need to convert minutes to hours, rounded off to 2 decimal places.I also need to display only up to 2 numbers after the decimal point. So if I have minutes as 650.Then hours should be 10.83

Here’s what I have so far:

Select round(Minutes/60.0,2) from ....

But in this case, if my minutes is, say,630 – hours is 10.5000000. But I want it as 10.50 only(after rounding). How do I achieve this?

Solution

Could you not cast your result as numeric(x,2)? Where x <= 38

select 
    round(630/60.0,2), 
    cast(round(630/60.0,2) as numeric(36,2))

Returns

10.500000   10.50
Answered By: Anonymous

Related Articles

  • Why iot_thread stack overflow is coming when I m…
  • Fix top buttons on scroll of list below
  • Python3 pandas dataframe round .5 always up
  • How can I format a decimal to always show 2 decimal places?
  • How to truncate float values?
  • How to convert number to words in java
  • TailwindCSS in Next.JS not rendering properly in Webkit
  • How do I convert datetime.timedelta to minutes,…
  • Round a double to 2 decimal places
  • How to round an average to 2 decimal places in PostgreSQL?
  • How to calculate Cohen's D across 50 points in R
  • How to get the subset dataframe from the dataframe…
  • How do I display first item in Json in vue js table?
  • Why does Math.Round(2.5) return 2 instead of 3?
  • Difference between numeric, float and decimal in SQL Server
  • How to round a Double to the nearest Int in swift?
  • I'm getting the data, trying to iterate the…
  • Python: Float to Decimal conversion and subsequent…
  • Active tab issue on page load HTML
  • How do you round to 1 decimal place in Javascript?
  • Select SQL Server database size
  • Change column type in pandas
  • Calculate time difference in minutes in SQL Server
  • Finding all possible combinations of numbers to…
  • Ukkonen's suffix tree algorithm in plain English
  • Rounding BigDecimal to *always* have two decimal places
  • don't know what went wrong nav bar with Tailwind CSS…
  • JavaScript gives NaN error on the page but variable…
  • I'm having problems getting sql data in a table to…
  • Fastest way to list all primes below N
  • Is floating point math broken?
  • Converting double to integer in Java
  • How to convert a data frame column to numeric type?
  • C compile error: Id returned 1 exit status
  • How to register a custom callback after Ember.RSVP.hash
  • Regular expression to match numbers with or without…
  • Sort table rows In Bootstrap
  • CSS3's border-radius property and…
  • Round number to nearest integer
  • The simplest possible JavaScript countdown timer?
  • Sorting 1 million 8-decimal-digit numbers with 1 MB of RAM
  • How to round a number to n decimal places in Java
  • how to use value of a column as input to a spatial operation
  • How can I get column names from a table in SQL Server?
  • How do you rotate canvas element to mouse position,…
  • MySQL server has gone away - in exactly 60 seconds
  • How to automate parameters passed into pandas.read_sql?
  • How do I obtain a Query Execution Plan in SQL Server?
  • How can I determine whether a 2D Point is within a Polygon?
  • Java 8: Difference between two LocalDateTime in…
  • How can I disable inherited css styles?
  • round() for float in C++
  • How to Round to the nearest whole number in C#
  • Limiting double to 3 decimal places
  • Grouping time values using Pandas Groupby
  • Binding between two arbitrary objects in Ember.js
  • How to round the double value to 2 decimal points?
  • Use SQL Server Management Studio to connect remotely…
  • Having trouble with my nav bar/header, It used to…
  • How to convert a factor to integernumeric without…
  • JavaScript seconds to time string with format hh:mm:ss
  • dateComponents(_, from, to) returning wrong data…
  • Retain precision with double in Java
  • Show/hide 'div' using JavaScript
  • state data can not be set using useState in reactjs
  • Is there a way to cast float as a decimal without…
  • How to round a floating point number up to a certain…
  • Hive/SQL Error when converting milliseconds to DDDD:HH:mm:ss
  • Javascript: formatting a rounded number to N decimals
  • How to return result of a SELECT inside a function…
  • SQL Format as of Round off removing decimals
  • How to convert minutes to hours/minutes and add…
  • Rounding a variable to two decimal places C#
  • How to find column names for all tables in all…
  • IsNumeric gives unexpected results in excel/vba for…
  • Conversion failed when converting the varchar value…
  • Python 3 Float Decimal Points/Precision
  • Converting from three decimals places to two decimal…
  • Truncate number to two decimal places without rounding
  • tSQL - Conversion from varchar to numeric works for…
  • how to add trailing or leading zero to `0.1201` or…
  • How to convert java.util.Date to java.sql.Date?
  • Polymer iron-media-query not working on dom-repeat element
  • How to deal with floating point number precision in…
  • How do you round a floating point number in Perl?
  • Sort a nested array of object when index is a key in…
  • Java - rounding double to 2 decimal places
  • Database development mistakes made by application developers
  • Declaring & Setting Variables in a Select Statement
  • How do I expand the output display to see more…
  • Rounded Button in Android
  • Programmatically Lighten or Darken a hex color (or…
  • Polymer paper-input doesn't seem to properly block…
  • HTML5 Canvas Resize (Downscale) Image High Quality?
  • Vue.js - Vuetify how to get rounded corners on cards?
  • Make only one post request with new state after…
  • Easy interview question got harder: given numbers…
  • Generate SQL Create Scripts for existing tables with Query
  • Blazor Can't Update UI
  • Best approach to remove time part of datetime in SQL Server

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Xcode – How to fix ‘NSUnknownKeyException’, reason: … this class is not key value coding-compliant for the key X” error?

Next Post:

Reading binary file and looping over each byte

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error