I have a table that has the fields: sCustID and severl other fields.. I want to "Group" together the like sCustid's by giving them a unique GroupID number.. If you run my code you will see what I'm trying to do.. The only problem is my code is backwards.. It groups the ones that are no alike together and the ones that are alike have different group numbers.. What am I doing wrong?
DECLARE @tmp TABLE (id TINYINT IDENTITY(1,1), sCustID CHAR(10))
SELECT sCustID FROM ctsapp.app.tblVRUInvReq
o.sCustID, o.id - omin.minid + 1 AS GroupNum
FROM @tmp o
(SELECT sCustID, MIN(id) minid FROM @tmp GROUP BY sCustID) AS omin ON
o.sCustID = omin.sCustID