0

I have 3 fields which are called game_series_count, game_series_wins and game_series_lost. I need to find wins percent.

select
       "game_series_count",
       "game_series_wins",
       "game_series_lost",
       round(( (game_series_wins / game_series_count) * 100), 1) as win_percent
from "statistic_teams"

but there is wrong result

game_series_count | game_series_wins | game_series_lost | win_percent
2   1   1   0
2   1   1   0
2   1   1   0
2   1   1   0
1   1   0   100
1   1   0   100
1   0   1   0
1   0   1   0
Jim Jones
  • 18,404
  • 3
  • 35
  • 44
Viktor
  • 1,532
  • 6
  • 22
  • 61

1 Answers1

1

You are doing integer division. The simplest method for your purpose is probably:

   round(game_series_wins * 100.0 / game_series_count, 1) as win_percent

Note that you can also economize on parentheses.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786