SELECT label
,label3
,lon_cen
,lat_cen
,lon3
,lat3
,antenna_height
,horizontal_angle
,CASE
WHEN round(atan((antenna_height / (2 * distance(lon3, lat3, lon_cen, lat_cen)))) * 180 / 3.14) < 0
THEN 0
WHEN round(atan((antenna_height / (2 * distance(lon3, lat3, lon_cen, lat_cen)))) * 180 / 3.14) > 9
THEN 9
ELSE round(atan((antenna_height / (2 * distance(lon3, lat3, lon_cen, lat_cen)))) * 180 / 3.14)
END AS m_angle
FROM table1