Note that there are some explanatory texts on larger screens.

plurals
  1. POTSql equality on groups of rows
    primarykey
    data
    text
    <p>I have a table that contains information on groups. There can be any number of members in a group. There is a group identifier and then an element identifier. I want to be able to in a single statement determine whether or not a given set exists in the table</p> <p>@groupTable is an example of the data that already exists in the database</p> <p>@inputData is the data that I want to see if it already exists in @groupTable</p> <pre><code>declare @groupData table ( groupIdentifier int, elementIdentifier uniqueidentifier ) insert into @groupData values (1, 'dfce40b1-3719-4e4c-acfa-65f728677700'), (1, '89e7e6be-cee8-40a7-8135-a54659e0d88c') declare @inputData table ( tempGroupIdentifier int, elementIdentifier uniqueidentifier ) insert into @inputData values (42, 'dfce40b1-3719-4e4c-acfa-65f728677700'), (42, '89e7e6be-cee8-40a7-8135-a54659e0d88c'), (55, 'dfce40b1-3719-4e4c-acfa-65f728677700'), (55, '2395a42c-94f4-4cda-a773-221b26ea5e44'), (55, 'f22db9df-a1f4-4078-b74c-90e34376eff6') </code></pre> <p>Now I want to run a query that will show the relationship of the sets, showing which groupIdentifier is associated with which tempGroupIdentifier. If there is no matching set then I need to know that too.</p> <pre><code>desired output: groupIdentifier, tempGroupIdentifier 1, 42 null, 55 </code></pre> <p>Does anyone any suggestions on how to approach this problem? </p> <p>I could probably pivot the rows and concat all elementIdentifiers into a giant string for each group that then do equality on, but that doesn't seem like a good solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload