Where clause based on another query in SQL Server












3















I have 3 tables in my database called Jobs, JobApplications, Candidates.



here they are.



Jobs




JobId | JobTitle
---------------------------
2115 | Software Engineer
2154 | Accountant
4562 | Sales Manager
4569 | Civil Engineer


JobApplications




JobApplicationId | CandidateId | JobId
---------------------------
8845 | 1120 | 2154
8912 | 1120 | 4569
9120 | 1555 | 2115
9450 | 1899 | 2115
9458 | 1991 | 4569
9488 | 1889 | 4569


Candidates




CandidateId | Email
----------------------------
1120 | can1@mail.com
1555 | can2@mail.com
1889 | can3@mail.com
1991 | can4@mail.com


What I want: A table with candidates and jobIds based on their previous applications.

Ex: if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" except the applied job to a table along with candidateId.



Is there any way to achieve this using SQL?




Can anybody help me?



The expected output would be like below




CandidateId | Suggest_jobId
------------------------------
1120 | 3565
1120 | 8956
1120 | 4565
1889 | 8965
1889 | 4568


So single candidate may have multiple job suggestions.










share|improve this question

























  • if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" didn't understand this logic can you please elaborate

    – Sanal Sunny
    Nov 16 '18 at 8:07











  • I need get all the jobs which are matching to there previous jobs by jobs title.basically I need to suggest new jobs to candidates based on their previous applications

    – Dhanushka Weerasinghe
    Nov 16 '18 at 8:09













  • Can you provide an example of the result that you want?

    – Thilina Nakkawita
    Nov 16 '18 at 8:11











  • The previous applications are stored under JobApplications and new jobs are stored under Jobs

    – Sanal Sunny
    Nov 16 '18 at 8:11
















3















I have 3 tables in my database called Jobs, JobApplications, Candidates.



here they are.



Jobs




JobId | JobTitle
---------------------------
2115 | Software Engineer
2154 | Accountant
4562 | Sales Manager
4569 | Civil Engineer


JobApplications




JobApplicationId | CandidateId | JobId
---------------------------
8845 | 1120 | 2154
8912 | 1120 | 4569
9120 | 1555 | 2115
9450 | 1899 | 2115
9458 | 1991 | 4569
9488 | 1889 | 4569


Candidates




CandidateId | Email
----------------------------
1120 | can1@mail.com
1555 | can2@mail.com
1889 | can3@mail.com
1991 | can4@mail.com


What I want: A table with candidates and jobIds based on their previous applications.

Ex: if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" except the applied job to a table along with candidateId.



Is there any way to achieve this using SQL?




Can anybody help me?



The expected output would be like below




CandidateId | Suggest_jobId
------------------------------
1120 | 3565
1120 | 8956
1120 | 4565
1889 | 8965
1889 | 4568


So single candidate may have multiple job suggestions.










share|improve this question

























  • if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" didn't understand this logic can you please elaborate

    – Sanal Sunny
    Nov 16 '18 at 8:07











  • I need get all the jobs which are matching to there previous jobs by jobs title.basically I need to suggest new jobs to candidates based on their previous applications

    – Dhanushka Weerasinghe
    Nov 16 '18 at 8:09













  • Can you provide an example of the result that you want?

    – Thilina Nakkawita
    Nov 16 '18 at 8:11











  • The previous applications are stored under JobApplications and new jobs are stored under Jobs

    – Sanal Sunny
    Nov 16 '18 at 8:11














3












3








3


1






I have 3 tables in my database called Jobs, JobApplications, Candidates.



here they are.



Jobs




JobId | JobTitle
---------------------------
2115 | Software Engineer
2154 | Accountant
4562 | Sales Manager
4569 | Civil Engineer


JobApplications




JobApplicationId | CandidateId | JobId
---------------------------
8845 | 1120 | 2154
8912 | 1120 | 4569
9120 | 1555 | 2115
9450 | 1899 | 2115
9458 | 1991 | 4569
9488 | 1889 | 4569


Candidates




CandidateId | Email
----------------------------
1120 | can1@mail.com
1555 | can2@mail.com
1889 | can3@mail.com
1991 | can4@mail.com


What I want: A table with candidates and jobIds based on their previous applications.

Ex: if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" except the applied job to a table along with candidateId.



Is there any way to achieve this using SQL?




Can anybody help me?



The expected output would be like below




CandidateId | Suggest_jobId
------------------------------
1120 | 3565
1120 | 8956
1120 | 4565
1889 | 8965
1889 | 4568


So single candidate may have multiple job suggestions.










share|improve this question
















I have 3 tables in my database called Jobs, JobApplications, Candidates.



here they are.



Jobs




JobId | JobTitle
---------------------------
2115 | Software Engineer
2154 | Accountant
4562 | Sales Manager
4569 | Civil Engineer


JobApplications




JobApplicationId | CandidateId | JobId
---------------------------
8845 | 1120 | 2154
8912 | 1120 | 4569
9120 | 1555 | 2115
9450 | 1899 | 2115
9458 | 1991 | 4569
9488 | 1889 | 4569


Candidates




CandidateId | Email
----------------------------
1120 | can1@mail.com
1555 | can2@mail.com
1889 | can3@mail.com
1991 | can4@mail.com


What I want: A table with candidates and jobIds based on their previous applications.

Ex: if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" except the applied job to a table along with candidateId.



Is there any way to achieve this using SQL?




Can anybody help me?



The expected output would be like below




CandidateId | Suggest_jobId
------------------------------
1120 | 3565
1120 | 8956
1120 | 4565
1889 | 8965
1889 | 4568


So single candidate may have multiple job suggestions.







sql sql-server tsql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 10:01









Rahul Neekhra

6001627




6001627










asked Nov 16 '18 at 8:02









Dhanushka WeerasingheDhanushka Weerasinghe

246




246













  • if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" didn't understand this logic can you please elaborate

    – Sanal Sunny
    Nov 16 '18 at 8:07











  • I need get all the jobs which are matching to there previous jobs by jobs title.basically I need to suggest new jobs to candidates based on their previous applications

    – Dhanushka Weerasinghe
    Nov 16 '18 at 8:09













  • Can you provide an example of the result that you want?

    – Thilina Nakkawita
    Nov 16 '18 at 8:11











  • The previous applications are stored under JobApplications and new jobs are stored under Jobs

    – Sanal Sunny
    Nov 16 '18 at 8:11



















  • if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" didn't understand this logic can you please elaborate

    – Sanal Sunny
    Nov 16 '18 at 8:07











  • I need get all the jobs which are matching to there previous jobs by jobs title.basically I need to suggest new jobs to candidates based on their previous applications

    – Dhanushka Weerasinghe
    Nov 16 '18 at 8:09













  • Can you provide an example of the result that you want?

    – Thilina Nakkawita
    Nov 16 '18 at 8:11











  • The previous applications are stored under JobApplications and new jobs are stored under Jobs

    – Sanal Sunny
    Nov 16 '18 at 8:11

















if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" didn't understand this logic can you please elaborate

– Sanal Sunny
Nov 16 '18 at 8:07





if someone has applied for the "software engineer" job position, I need the all other jobs with title "software engineer" didn't understand this logic can you please elaborate

– Sanal Sunny
Nov 16 '18 at 8:07













I need get all the jobs which are matching to there previous jobs by jobs title.basically I need to suggest new jobs to candidates based on their previous applications

– Dhanushka Weerasinghe
Nov 16 '18 at 8:09







I need get all the jobs which are matching to there previous jobs by jobs title.basically I need to suggest new jobs to candidates based on their previous applications

– Dhanushka Weerasinghe
Nov 16 '18 at 8:09















Can you provide an example of the result that you want?

– Thilina Nakkawita
Nov 16 '18 at 8:11





Can you provide an example of the result that you want?

– Thilina Nakkawita
Nov 16 '18 at 8:11













The previous applications are stored under JobApplications and new jobs are stored under Jobs

– Sanal Sunny
Nov 16 '18 at 8:11





The previous applications are stored under JobApplications and new jobs are stored under Jobs

– Sanal Sunny
Nov 16 '18 at 8:11












2 Answers
2






active

oldest

votes


















2














We can make use of a simple CTE to do the job



 WITH cte AS 
(
SELECT j.JobId,
j.JobTitle,
ja.CandidateId
FROM JobApplications ja
JOIN Jobs j ON j.JobId=ja.JobId
)
SELECT j.JobTitle,
c.CandidateId
FROM Jobs j
JOIN cte c ON j.JobTitle like CONCAT('%',c.JobTitle,'%') AND c.JobId!=j.JobId





share|improve this answer


























  • Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

    – Dhanushka Weerasinghe
    Nov 16 '18 at 10:06



















0














I have simple and basic solution for you. I have used table function to split applied jobs first. Then I used these results to find similarity using Sanal Sunny's script.



The table function creation script:



CREATE  FUNCTION [dbo].[Tbl_Fn_Split](
@InputText VARCHAR(8000)
, @Delimiter VARCHAR(8000) = ' ' -- delimiter that separates items
) RETURNS @List TABLE (Result VARCHAR(8000))

BEGIN
DECLARE @aResult VARCHAR(8000)
WHILE CHARINDEX(@Delimiter,@InputText,0) <> 0
BEGIN
SELECT
@aResult=RTRIM(LTRIM(SUBSTRING(@InputText,1,CHARINDEX(@Delimiter,@InputText,0)-1))),
@InputText=RTRIM(LTRIM(SUBSTRING(@InputText,CHARINDEX(@Delimiter,@InputText,0)+LEN(@Delimiter),LEN(@InputText))))

IF LEN(@aResult) > 0
INSERT INTO @List SELECT @aResult
END

IF LEN(@InputText) > 0
INSERT INTO @List SELECT @InputText

RETURN

END


The finding similarity script which is based on Sanal Sunny's answer:



 WITH cte AS 
(
SELECT j.JobId,
j.JobTitle,
ja.CandidateId,
A.Result
FROM JobApplications ja
JOIN Jobs j ON j.JobId=ja.JobId
CROSS APPLY (SELECT * FROM DBO.[Tbl_Fn_Split](j.JobTitle,' ')) A
)
SELECT DISTINCT c.CandidateId
,j.JobId
,j.JobTitle
FROM Jobs j
JOIN cte c ON j.JobTitle LIKE '%'+c.Result+'%'AND c.JobId!=j.JobId





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333693%2fwhere-clause-based-on-another-query-in-sql-server%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    We can make use of a simple CTE to do the job



     WITH cte AS 
    (
    SELECT j.JobId,
    j.JobTitle,
    ja.CandidateId
    FROM JobApplications ja
    JOIN Jobs j ON j.JobId=ja.JobId
    )
    SELECT j.JobTitle,
    c.CandidateId
    FROM Jobs j
    JOIN cte c ON j.JobTitle like CONCAT('%',c.JobTitle,'%') AND c.JobId!=j.JobId





    share|improve this answer


























    • Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

      – Dhanushka Weerasinghe
      Nov 16 '18 at 10:06
















    2














    We can make use of a simple CTE to do the job



     WITH cte AS 
    (
    SELECT j.JobId,
    j.JobTitle,
    ja.CandidateId
    FROM JobApplications ja
    JOIN Jobs j ON j.JobId=ja.JobId
    )
    SELECT j.JobTitle,
    c.CandidateId
    FROM Jobs j
    JOIN cte c ON j.JobTitle like CONCAT('%',c.JobTitle,'%') AND c.JobId!=j.JobId





    share|improve this answer


























    • Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

      – Dhanushka Weerasinghe
      Nov 16 '18 at 10:06














    2












    2








    2







    We can make use of a simple CTE to do the job



     WITH cte AS 
    (
    SELECT j.JobId,
    j.JobTitle,
    ja.CandidateId
    FROM JobApplications ja
    JOIN Jobs j ON j.JobId=ja.JobId
    )
    SELECT j.JobTitle,
    c.CandidateId
    FROM Jobs j
    JOIN cte c ON j.JobTitle like CONCAT('%',c.JobTitle,'%') AND c.JobId!=j.JobId





    share|improve this answer















    We can make use of a simple CTE to do the job



     WITH cte AS 
    (
    SELECT j.JobId,
    j.JobTitle,
    ja.CandidateId
    FROM JobApplications ja
    JOIN Jobs j ON j.JobId=ja.JobId
    )
    SELECT j.JobTitle,
    c.CandidateId
    FROM Jobs j
    JOIN cte c ON j.JobTitle like CONCAT('%',c.JobTitle,'%') AND c.JobId!=j.JobId






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 16 '18 at 11:34









    Dhanushka Weerasinghe

    246




    246










    answered Nov 16 '18 at 8:16









    Sanal SunnySanal Sunny

    6629




    6629













    • Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

      – Dhanushka Weerasinghe
      Nov 16 '18 at 10:06



















    • Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

      – Dhanushka Weerasinghe
      Nov 16 '18 at 10:06

















    Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

    – Dhanushka Weerasinghe
    Nov 16 '18 at 10:06





    Thanks! this answer is good. Can we get the this without exact job title matching. as example. if someone has applied for "software engineer" he should get job suggestions with job title like "Senior Software Engineer", "Java Software engineer", "UI/UX Software Engineer".

    – Dhanushka Weerasinghe
    Nov 16 '18 at 10:06













    0














    I have simple and basic solution for you. I have used table function to split applied jobs first. Then I used these results to find similarity using Sanal Sunny's script.



    The table function creation script:



    CREATE  FUNCTION [dbo].[Tbl_Fn_Split](
    @InputText VARCHAR(8000)
    , @Delimiter VARCHAR(8000) = ' ' -- delimiter that separates items
    ) RETURNS @List TABLE (Result VARCHAR(8000))

    BEGIN
    DECLARE @aResult VARCHAR(8000)
    WHILE CHARINDEX(@Delimiter,@InputText,0) <> 0
    BEGIN
    SELECT
    @aResult=RTRIM(LTRIM(SUBSTRING(@InputText,1,CHARINDEX(@Delimiter,@InputText,0)-1))),
    @InputText=RTRIM(LTRIM(SUBSTRING(@InputText,CHARINDEX(@Delimiter,@InputText,0)+LEN(@Delimiter),LEN(@InputText))))

    IF LEN(@aResult) > 0
    INSERT INTO @List SELECT @aResult
    END

    IF LEN(@InputText) > 0
    INSERT INTO @List SELECT @InputText

    RETURN

    END


    The finding similarity script which is based on Sanal Sunny's answer:



     WITH cte AS 
    (
    SELECT j.JobId,
    j.JobTitle,
    ja.CandidateId,
    A.Result
    FROM JobApplications ja
    JOIN Jobs j ON j.JobId=ja.JobId
    CROSS APPLY (SELECT * FROM DBO.[Tbl_Fn_Split](j.JobTitle,' ')) A
    )
    SELECT DISTINCT c.CandidateId
    ,j.JobId
    ,j.JobTitle
    FROM Jobs j
    JOIN cte c ON j.JobTitle LIKE '%'+c.Result+'%'AND c.JobId!=j.JobId





    share|improve this answer




























      0














      I have simple and basic solution for you. I have used table function to split applied jobs first. Then I used these results to find similarity using Sanal Sunny's script.



      The table function creation script:



      CREATE  FUNCTION [dbo].[Tbl_Fn_Split](
      @InputText VARCHAR(8000)
      , @Delimiter VARCHAR(8000) = ' ' -- delimiter that separates items
      ) RETURNS @List TABLE (Result VARCHAR(8000))

      BEGIN
      DECLARE @aResult VARCHAR(8000)
      WHILE CHARINDEX(@Delimiter,@InputText,0) <> 0
      BEGIN
      SELECT
      @aResult=RTRIM(LTRIM(SUBSTRING(@InputText,1,CHARINDEX(@Delimiter,@InputText,0)-1))),
      @InputText=RTRIM(LTRIM(SUBSTRING(@InputText,CHARINDEX(@Delimiter,@InputText,0)+LEN(@Delimiter),LEN(@InputText))))

      IF LEN(@aResult) > 0
      INSERT INTO @List SELECT @aResult
      END

      IF LEN(@InputText) > 0
      INSERT INTO @List SELECT @InputText

      RETURN

      END


      The finding similarity script which is based on Sanal Sunny's answer:



       WITH cte AS 
      (
      SELECT j.JobId,
      j.JobTitle,
      ja.CandidateId,
      A.Result
      FROM JobApplications ja
      JOIN Jobs j ON j.JobId=ja.JobId
      CROSS APPLY (SELECT * FROM DBO.[Tbl_Fn_Split](j.JobTitle,' ')) A
      )
      SELECT DISTINCT c.CandidateId
      ,j.JobId
      ,j.JobTitle
      FROM Jobs j
      JOIN cte c ON j.JobTitle LIKE '%'+c.Result+'%'AND c.JobId!=j.JobId





      share|improve this answer


























        0












        0








        0







        I have simple and basic solution for you. I have used table function to split applied jobs first. Then I used these results to find similarity using Sanal Sunny's script.



        The table function creation script:



        CREATE  FUNCTION [dbo].[Tbl_Fn_Split](
        @InputText VARCHAR(8000)
        , @Delimiter VARCHAR(8000) = ' ' -- delimiter that separates items
        ) RETURNS @List TABLE (Result VARCHAR(8000))

        BEGIN
        DECLARE @aResult VARCHAR(8000)
        WHILE CHARINDEX(@Delimiter,@InputText,0) <> 0
        BEGIN
        SELECT
        @aResult=RTRIM(LTRIM(SUBSTRING(@InputText,1,CHARINDEX(@Delimiter,@InputText,0)-1))),
        @InputText=RTRIM(LTRIM(SUBSTRING(@InputText,CHARINDEX(@Delimiter,@InputText,0)+LEN(@Delimiter),LEN(@InputText))))

        IF LEN(@aResult) > 0
        INSERT INTO @List SELECT @aResult
        END

        IF LEN(@InputText) > 0
        INSERT INTO @List SELECT @InputText

        RETURN

        END


        The finding similarity script which is based on Sanal Sunny's answer:



         WITH cte AS 
        (
        SELECT j.JobId,
        j.JobTitle,
        ja.CandidateId,
        A.Result
        FROM JobApplications ja
        JOIN Jobs j ON j.JobId=ja.JobId
        CROSS APPLY (SELECT * FROM DBO.[Tbl_Fn_Split](j.JobTitle,' ')) A
        )
        SELECT DISTINCT c.CandidateId
        ,j.JobId
        ,j.JobTitle
        FROM Jobs j
        JOIN cte c ON j.JobTitle LIKE '%'+c.Result+'%'AND c.JobId!=j.JobId





        share|improve this answer













        I have simple and basic solution for you. I have used table function to split applied jobs first. Then I used these results to find similarity using Sanal Sunny's script.



        The table function creation script:



        CREATE  FUNCTION [dbo].[Tbl_Fn_Split](
        @InputText VARCHAR(8000)
        , @Delimiter VARCHAR(8000) = ' ' -- delimiter that separates items
        ) RETURNS @List TABLE (Result VARCHAR(8000))

        BEGIN
        DECLARE @aResult VARCHAR(8000)
        WHILE CHARINDEX(@Delimiter,@InputText,0) <> 0
        BEGIN
        SELECT
        @aResult=RTRIM(LTRIM(SUBSTRING(@InputText,1,CHARINDEX(@Delimiter,@InputText,0)-1))),
        @InputText=RTRIM(LTRIM(SUBSTRING(@InputText,CHARINDEX(@Delimiter,@InputText,0)+LEN(@Delimiter),LEN(@InputText))))

        IF LEN(@aResult) > 0
        INSERT INTO @List SELECT @aResult
        END

        IF LEN(@InputText) > 0
        INSERT INTO @List SELECT @InputText

        RETURN

        END


        The finding similarity script which is based on Sanal Sunny's answer:



         WITH cte AS 
        (
        SELECT j.JobId,
        j.JobTitle,
        ja.CandidateId,
        A.Result
        FROM JobApplications ja
        JOIN Jobs j ON j.JobId=ja.JobId
        CROSS APPLY (SELECT * FROM DBO.[Tbl_Fn_Split](j.JobTitle,' ')) A
        )
        SELECT DISTINCT c.CandidateId
        ,j.JobId
        ,j.JobTitle
        FROM Jobs j
        JOIN cte c ON j.JobTitle LIKE '%'+c.Result+'%'AND c.JobId!=j.JobId






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 10:40









        Zeki GumusZeki Gumus

        1,445313




        1,445313






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333693%2fwhere-clause-based-on-another-query-in-sql-server%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma