Correction to fa44b847434aa1f62d78d713d5b9dc4efcbd8380

Also added missing SQL