Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Clause Group By

Author  Topic 

cms9651
Starting Member

28 Posts

Posted - 2013-08-30 : 09:58:38
Hi all, hope in your help.

I try this sql query:

SELECT
[NAMES], [NUMBER]
FROM
[CV].[dbo].[T40]
WHERE
[NUMBER] = '44644'
GROUP BY
[NAMES], [NUMBER];

the output is:
[CODE]
NAMES NUMBER
BENCORE S.R.L. 44644
BENCORES.R.L. 44644
[/CODE]
I need instead this other output, can you help me?

NAMES NUMBER
BENCORE S.R.L. 44644

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-30 : 13:14:28
[code]SELECT
MIN([NAMES]) AS [NAMES], [NUMBER]
FROM
[CV].[dbo].[T40]
WHERE
[NUMBER] = '44644'
GROUP BY
[NUMBER];[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-31 : 05:16:49
ideally you would like to do some kind of fuzzy grouping to get these similar names grouped together. If you want you can run a MDM type logic to create standardized value out of these duplicate pattern.
Taking MIN may not always give you result you're after as there may be completely different entities whom you may need to list out separately

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -