Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:44:29+00:00 2026-06-02T01:44:29+00:00

I want to use left outer join like this: SELECT … FROM Table1 LEFT

  • 0

I want to use left outer join like this:

    SELECT ...
FROM Table1
LEFT OUTER JOIN
(SELECT only e.g. 3rd record... , SomeField FROM Table2) tbl2
  ON Table1.SomeField = tbl2.SomeField

How can I do that, if I need the subquery to select not just the 3rd record from Table2, but the 3rd record among the Table2 records that have SomeField = Table1.SomeField?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:44:31+00:00Added an answer on June 2, 2026 at 1:44 am

    If this is sql server 2005 or newer, you might use row_number():

    LEFT JOIN
    (
       select *
         from
         (
           select *,
                  row_number() over (order by something) rn
             from Table2
            where Table2.Column = Table1.Column
         ) a
        where a.rn = 3
    ) a
    

    Unfortunately you need to nest it a level deeper because you cannot use row_number in a condition directly.

    EDIT:

    My bad – i didn’t really notice the join part. If you want to join derived table, use this:

    LEFT JOIN
    (
       select *,
              row_number() over (partition by SomeField order by something) rn
         from Table2
    ) tbl2
      ON Table1.SomeField = tbl2.SomeField
     AND tbl2.rn = 3
    

    Note: you need ORDER BY in row_number() to keep things consistent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SELECT * FROM left_table OUTER JOIN right_table on left_table.name = righ t_table.name; SELECT *
i want use some data from a website with web service. i have a
I have a easy select tag: <select> <option></option> <option></option> </select> Then I want use
I use OUTER JOIN to get values stored in rows and show them as
I am trying to figure out how to use multiple left outer joins to
I want to select everything from table one, which contains a column JID. These
I have two tables that I am outer joining together: Post left outer join
I have this query to get the first result I want from this post
I have two table i want to add one condition while using LEFT OUTER
I'm trying to implement a query in LINQ that uses a left outer join

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.