Solved

sql server query

Posted on 2016-08-15
2
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

752 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