# Issue

I am trying to get the percent and it just shows up as zero. I want to show two decimal places such as 0.65 Here is a piece of the query I am selecting:

```
select count(numbers)/count(othernumbers) decimal(3,2) as"rate"
```

if I use this it shows up as 0 and gets rid of the rest

```
select count(numbers)/count(othernumbers) as"rate"
```

# Solution

```
SELECT FORMAT(this / that, 2) as rate
```

Meanwhile, I question whether `COUNT(numbers)`

is what you want. That counts how many rows have a non-NULL value in the column `numbers`

.

Also, fraction is usually more like `x / (x+y)`

-- meaning the fraction of the total (x+y) that is x.

A "percentage" needs `100*`

somewhere. 13/20 is the *fraction* 0.65 or the *percentage* 65.00 .

Answered By - Rick James Answer Checked By - Terry (PHPFixing Volunteer)

## 0 Comments:

## Post a Comment

Note: Only a member of this blog may post a comment.