Query:
select
max(pin::bigint) as example,
count(*) num_properties,
ROUND(current_total/current_market_value::numeric, 2::int) as assessment_level
from taxes
where
current_market_value !=0
and property_class>=500
and property_class<600
group by assessment_level
order by assessment_level;
example | num_properties | assessment_level
----------------+----------------+------------------
32214170350000 | 2318 | 0.00
32333310240000 | 2199 | 0.01
32334120010000 | 2352 | 0.02
32334120030000 | 2393 | 0.03
32334130300000 | 2382 | 0.04
33203000380000 | 2375 | 0.05
33081000098057 | 2469 | 0.06
32334000230000 | 2346 | 0.07
32334100350000 | 2302 | 0.08
33203000210000 | 2359 | 0.09
33292000110000 | 2114 | 0.10
33201040080000 | 1936 | 0.11
33192050290000 | 1918 | 0.12
33192050240000 | 2578 | 0.13
33301000270000 | 3055 | 0.14
33303020070000 | 2450 | 0.15
33292000120000 | 2562 | 0.16
33301000120000 | 2645 | 0.17
33201040020000 | 2974 | 0.18
33203000390000 | 2375 | 0.19
33291000100000 | 2413 | 0.20
33192050350000 | 2394 | 0.21
33203000200000 | 2311 | 0.22
33072030100000 | 2980 | 0.23
33072010400000 | 4453 | 0.24
33303000140000 | 33499 | 0.25
17151070470000 | 2 | 0.26
17161190520000 | 3 | 0.27
19094110120000 | 1 | 0.28
25221110210000 | 18 | 0.29
19094110290000 | 4 | 0.30
25221110060000 | 6 | 0.31
27044170308002 | 40 | 0.33
20091090136002 | 1 | 0.43
19094110280000 | 1 | 0.45
14202140260000 | 1 | 0.47
17093330108013 | 1 | 0.50
(37 rows)
You're casting the PIN to
bigint
but some PINs have leading zeros. Wouldn'tbigint
chop off that leading zero?