![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi there -- I'm writing a SQL query that works something like this: SELECT a, b, a/b AS col_name FROM TABLE Dividing a by b can result in a value above or below 1, e.g. 1.234 or 0.123. If the value is below 1, I don't want the preceding zero, e.g. .123. I've been using a STR() function to format it to three decimal points, e.g.: STR(a/b, 5, 3) AS col_name ... but for values below 1 it'll look like 0.123. Any suggestions for how I can make this look like .123? Thanks in advance. |
#3
| |||
| |||
|
|
I'm writing a SQL query that works something like this: SELECT a, b, a/b AS col_name FROM TABLE Dividing a by b can result in a value above or below 1, e.g. 1.234 or 0.123. If the value is below 1, I don't want the preceding zero, e.g. .123. I've been using a STR() function to format it to three decimal points, e.g.: STR(a/b, 5, 3) AS col_name ... but for values below 1 it'll look like 0.123. Any suggestions for how I can make this look like .123? |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Hi there -- I'm writing a SQL query that works something like this: SELECT a, b, a/b AS col_name FROM TABLE Dividing a by b can result in a value above or below 1, e.g. 1.234 or 0.123. If the value is below 1, I don't want the preceding zero, e.g. .123. I've been using a STR() function to format it to three decimal points, e.g.: STR(a/b, 5, 3) AS col_name ... but for values below 1 it'll look like 0.123. Any suggestions for how I can make this look like .123? Thanks in advance. |
![]() |
| Thread Tools | |
| Display Modes | |
| |