sql get row distinct count in table