Skip to content
Loading
  • 0
    I understand that the SQL statement should be:
     
    SELECT F.SSN
    FROM Families F
    INNER JON Placement P ON P.SSN = F.SSN
    WHERE F.DateTom >= GETDATE()
     
    But this is not the whole question regarding the requirements that I have listed.
     
    I have problems when I search for a child that has no placement. How to search for a sibling in the other family and check if the sibling has a placement. The child that has no placement has a sibling that has placement which fulfills the requirement and shall show the both divided families, i.e the family before divorce and split.
    0
  • 0
    I have tried with this query and with this query I get the whole family before the divorce. 
    But how to do an SQL where I can search for a specific child or parent and get the whole family. 
     
    SELECT Family.*
    FROM Family AS Family
    WHERE EXISTS (
    SELECT TOP 1 1
    FROM Family F
    INNER JOIN Placement AS P ON (P.SSN = F.SSN)
    WHERE F.DateTom != NULL AND P.DateTom = NULL
    UNION
    SELECT 1
    FROM Family F
    INNER JOIN Placement AS P ON (P.SSN = F.SSN)
    WHERE P.DateTom = NULL AND F.DateTom = NULL)
    AND Family.DateTom != NULL
    0
  • Laxmidhar Sahoo
    0
    I could not understand .I rthink you want to use left join for family table
    0