Select [GLAccountName].[DBId] as [ResDBId], [GLAccountName].[Number], [GLAccountName].[LanguageId], [GLAccountName].[GLAccPlanTypeId], count(*) as [Result] From [GLAccountName] where Not [GLAccountName].[Number] = '' Group by [GLAccountName].[DBId], [GLAccountName].[Number], [GLAccountName].[LanguageId], [GLAccountName].[GLAccPlanTypeId] having count(*) > 1 Order by [GLAccountName].[DBId], [GLAccountName].[Number], [GLAccountName].[LanguageId], [GLAccountName].[GLAccPlanTypeId]

Select distinct [ResDBId] as [DBId] from (Select [GLAccountName].[DBId] as [ResDBId], [GLAccountName].[Number], [GLAccountName].[LanguageId], [GLAccountName].[GLAccPlanTypeId], count(*) as [Result] From [GLAccountName] where Not [GLAccountName].[Number] = '' Group by [GLAccountName].[DBId], [GLAccountName].[Number], [GLAccountName].[LanguageId], [GLAccountName].[GLAccPlanTypeId] having count(*) > 1) as [Result]