Wow. I'm impressed. Very cool.
I need to study a little to figure out *why* it works and to learn the technique for other applications, but it definitely is the result I want
Thanks so much.
>Try
>
>;with cte as (select *, count(Symbol) over (partition by [Name]) as Cnt from Symbology)
>
>select * from cte where Cnt > 1
>
>>symbology table as
>>
>>symbol char(6)
>>name varchar(100)
>>
>>I want to select all the symbols that belong to names that have at least one match ( on the entire name )
>>
>>so if I have
>>
>>ATT American Telephone and Telegraph
>>ATT& American Telephone and Telegraph
>>ATTB American Telephone and Telegraph
>>AG American Greetings
>>AA American Airlines
>>AIR Associated Industry Resources
>>AUR Associated Urban Renwal
>>
>>I only want to see
>>
>>ATT
>>ATT&
>>ATTB
>>
>>in the result set. Right now I am getting AG, AA AIR and AUR as they have matchs on the first three character.
>>
>>I want to group by name so that the only group having count(symbol) > 1 in the set above is the first three
>>
>>
>>>Can you please translate in English what do you want to achieve? Better provide input and desired output.
>>>
>>>>I want to find all rows representing records that have at least one exact match on a varchar(100) column
>>>>
>>>>I am current doing
>>>>
>>>>
>>>>SELECT
>>>> name
>>>> ,symbol
>>>> ,from_date
>>>> ,thru_date
>>>> FROM [iSource100].[dbo].[Symbology]
>>>> where exists ( select Name, COUNT(symbol) as cntsym from Symbology
>>>> where thru_date > GETDATE()
>>>> group by Name having COUNT(symbol) > 1 )
>>>> and thru_date > GETDATE()
>>>>order by name
>>>>
>>>>
>>>>but from the results I'm getting it appears a 'match' for grouping seems to be based on just the first three characters of the Name column.
>>>>
>>>>How can I tell it to group by the entire contents of Name being an exact match?
>>>>
>>>>TIA
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.