i gave an user defined function inside a group by clause and it behaved abnormally returning wrong results. then i had this doubt... whether is it a normal behavior for a group by clause to accept functions? I had a workaround to see the results. in that, my select query returns weird incorrect results and i have attached the complete workaround below. can anyone explain me that weird behavior? create table aa(a int, b int) insert into aa select a = 1,b = 1 union all select a = 1,b = 3 union all select a = 1,b = 4 union all select a = 2,b = 5 union all select a = 2,b = 2 create function ab (@a int, @b int) returns int as begin return (@a - @b) end select dbo.ab(10,a) A, dbo.ab(10,1) B from aa group by dbo.ab(10,a) Thanks, Ram "It is easy to write code for a spec and walk in water, provided, both are freezed..."