Avatar of PeterBaileyUk
PeterBaileyUk
 asked on

sql server query

I have a query just for demonstration, I need to create a query that tells me where strshort matches but the client is different its all in one table so I am not sure how to create that.

My feeble attempt after looking at microsoft site
SELECT StrShort1.StrShort, StrShort2.ClientName
FROM TblWords.strshort AS StrShort1
     JOIN TblWords.strshort AS StrShort2
       ON (StrShort1.strshort = StrShort2.strshort)
WHERE StrShort1.clientName <>StrShort1.clientName;

Open in new window



<TblWords StrShort="V70 XL" ClientName="Abi" />
<TblWords StrShort="V70 XL" ClientName="Cap" />
<TblWords StrShort="V70 XL" ClientName="Glass" />
<TblWords StrShort="V70 XL" ClientName="Smmt" />

the above would present as a match as strshort is all the same but with different clients

<TblWords StrShort="V70 XL 10V" ClientName="Abi" />
<TblWords StrShort="V70 XL 10V" ClientName="Smmt" />

the above would present as a match as strshort is all the same but with different clients

<TblWords StrShort="V70 XL" ClientName="Smmt" />
<TblWords StrShort="V70 XL 10V" ClientName="Abi" />

the above dont match as strshort is different.

use Dictionary
select StrShort, ClientName
from TblWords
where StrShort like'v70%xl%'
group by StrShort,  ClientName

Open in new window

Microsoft SQL Server

Avatar of undefined
Last Comment
PeterBaileyUk

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Randy Peterson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
PeterBaileyUk

ASKER
Thank you
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23