select g.bill_no, g.PREV_VAL, G.RETURN_VAL, wg.prev_val, wg.curr_val, wg.return_val , g.owner_name, wg.lastname, WG.REALKEY, 
	G.MAP, G.BLOCK, G.PARCEL, G.SUBPARC, WG.PARCEL_NO
	, convert(int,g.ST_VALUE1 )
	+ convert(int,g.ST_VALUE2 )
	+ convert(int,g.ST_VALUE3 )
	+ convert(int,g.ST_VALUE4 )
	+ convert(int,g.ST_VALUE5 )
	+ convert(int,g.ST_VALUE6 )
	+ convert(int,g.ST_VALUE7 )
	+ convert(int,g.ST_VALUE8 )
	+ convert(int,g.ST_VALUE9 )
	+ convert(int,g.ST_VALUE10) GSI_CURR_VAL
	, wg.CURR_VAL 
from MCDUFFIE_GSI.dbo.PARCEL g
LEFT join (
	SELECT REPLACE(O.LASTNAME,',','') AS LASTNAME, O.ADDRESS1, O.ADDRESS2, O.ADDRESS3, O.CITY, O.STATE, O.ZIP
		, P.REALKEY, P.PREV_VAL, P.CURR_VAL, P.RETURN_VAL, P.STREET_NAM, P.HOUSE_NO, P.TAXDISTRIC, P.PARCEL_NO
	FROM [WINGAP].AY2021.DBO.REALPROP  P 
	LEFT JOIN [WINGAP].AY2021.DBO.OWNER O ON O.OWNKEY = P.OWNKEY 
	) wg ON G.MAP+G.PARCEL+REPLACE(REPLACE(G.SUBPARC,'000',''),'XXX','')=WG.PARCEL_NO 

	 where g.bill_year=2021 and RIGHT(G.ST_CODE1,1) BETWEEN '1' AND '9' --AND G.PREV_VAL=WG.PREV_VAL AND G.RETURN_VAL=WG.RETURN_VAL
	 AND WG.REALKEY IS NULL

--SELECT * FROM MCDUFFIE_GSI.DBO.PARCEL 	 where bill_year=2021 and RIGHT(ST_CODE1,1) BETWEEN '1' AND '9' --12543