insert into #tmp (CityID, CityName, TotalOrder)
Select distinct sr.RID as CityID,
sr.Rname as CityName
From #tmpID tid
Inner join StateRegions Sr on Sr.RID = tid.CityID
Group by Sr.RName,
sr.RID
Order by sr.RName
stai cercando di inserire 3 colonne in #tmp, ma la query restituisce solo 2 colonne
Sospetto che tu voglia Conte(*) o Somma(ordini) come terza colonna