Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query inner joins
    primarykey
    data
    text
    <p>I am working on SQL Server 2008 R2. I have two tables let us say <code>TblGroup</code> and <code>TblComplatedDetails</code>. </p> <p>TblGroup contains the name of Groups along with <code>MemberId</code> and <code>GroupType (i.e. in Daily, Weekly, Start, End)</code> and <code>TblComplatedDetails</code> contains <code>GroupId (i.e. foreign key of TblGroup)</code> along with completed datetime. Now I want all the group of specific <code>MemberId</code> except <code>GroupType="End"</code> AND "Start" type of Group only if it has no record in TblCompletedDetails. So the record set is something like below : </p> <pre><code>TblGroup ================================== Id MemberId GroupType ================================== 1 1 Daily 2 2 Daily 3 3 Daily 4 1 Weekly 5 1 Start 6 2 Weekly 7 2 Start 8 2 End 9 1 End 10 1 End TblCompletedDetails ====================================== Id GroupId CompletedDate ====================================== 1 1 xxxxxxxxxxxxxx 2 2 xxxxxxxxxxxxxx 3 3 xxxxxxxxxxxxxx 4 4 xxxxxxxxxxxxxx 5 1 xxxxxxxxxxxxxx 6 2 xxxxxxxxxxxxxx 7 3 xxxxxxxxxxxxxx 8 5 xxxxxxxxxxxxxx 9 6 xxxxxxxxxxxxxx </code></pre> <p>So for MemberId = 1 the desired Groups can be :</p> <pre><code>======= GroupId ======= 1 4 </code></pre> <p>But for MemberId = 2 the desired resule is : </p> <pre><code>======= GroupId ======= 2 6 7 </code></pre> <p>Because 7 is a "Start" type of Group that has not foreign key in TblCompletedDetails. Can anyone have idea? Awaiting for your valuable response.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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