Fix nasty site id lost sleeping bug

Select `g.SITE_ID` not `e.TENANT`, the latter might be Null.