Solved

sql server query

Posted on 2016-08-15
2
41 Views
Last Modified: 2016-08-15
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

0
Comment
Question by:PeterBaileyUk
2 Comments
 
LVL 8

Accepted Solution

by:
Randy Peterson earned 500 total points
ID: 41756611
Try this:

SELECT *
FROM TblWords A
JOIN TblWords B
            ON A.StrShort = B.StrShort
                  AND A.ClientName <> B.ClientName
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 41756660
Thank you
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question