Clover Nguyen
Clover Nguyen

Reputation: 15

Formatting integers with a decimal place in sql query

I had the table, resulted from a query as follow:

Lasiorhinus 100
Macrotis    100
Myrmecobius 100
Panthera    50
Sarcophilus 100

The query is sth like this:

select round (count(A) / count(B), 1)

But I'd like the numbers to be formatted as follow:

Lasiorhinus 100.0
Macrotis    100.0
Myrmecobius 100.0
Panthera    50.0
Sarcophilus 100.0

Could anyone help me to format the integer 50 => 50.0 with ROUND(number, 1) function? thank you.

Upvotes: 1

Views: 87

Answers (1)

Mitch Wheat
Mitch Wheat

Reputation: 300559

One solution (SQL Server) would be:

select format(round(count(A) / count(B), 1), 'N1')

Ref.:

Upvotes: 1

Related Questions