Dear experts
I am using this sql (our database is Ms SQL Server 2008 and we have defined our sql in a spring xm file)
select distinct cg.NAME as CustomerGroup,COUNT(cg.NAME) as GroupCount FROM PAC.CustomerGroupMap cgmap, PAC.CustomerGroup cg, PAC.Customer Customer, PAC.Customercluster customerRef where cg.CustomerGROUPID = cgmap.CustomerGROUPID and cgmap.CustomerID = Customer.CustomerID and customerRef.CustomerGROUPID = cgmap.CustomerGROUPID and (customerRef.MODIFIEDBY != 'Migration' OR customerRef.ISACTIVE != 'F') and customerRef.CLUSTERID = ? group by cg.NAME having COUNT(cg.NAME) = 1