Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sql server query

Posted on 2016-08-15
2
Medium Priority
?
53 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

719 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