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 8654767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:52:00+00:00 2026-06-12T14:52:00+00:00

I have 2 sql queries that return different results. Both queries use the same

  • 0

I have 2 sql queries that return different results.
Both queries use the same join operation but with different binding to the join parameter inside the IN clause.

on the first one,I reffer directly to the join parameter.
on the second I use free context query.
I’m getting different results and I’d like to understand why.

-- this one returns 13 tuples
select c.companyname
    from companies as c
    join stocklist as s
    using (companyid)
    where s.price in((select MAX(s.price)),( select MIN(s.price)));




--this one returns two tuples. as it should
select companyname
    from companies join stockslist
    using (companyid)
    where price in(
    (select max(price) from stockslist),(select min(price) from stockslist)
    );
  • 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-12T14:52:01+00:00Added an answer on June 12, 2026 at 2:52 pm

    You can think of s as a named instance of the stockslist table. It isn’t exactly true, but it helps to think of it that way.

    When you use a named table from the outer query inside of an inner query, it performs the inner query for each row of the outer table using the values from that particular row.

    Your top query is essentially equivalent to:

    -- this one returns 13 tuples
    select c.companyname
        from companies as c
        join stocklist as s
        using (companyid)
        where s.price in(s.price,s.price)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a LINQ to SQL DataContext that queries four different tables. But I
I have functions in place that will convert the results of sql queries into
I have two SQL queries producing different results when I would expect them to
I have two very similar SQL queries that return a count of minutes spent
I have several sql queries that I simply want to fire at the database.
I have six SQL queries that I script though R that each take a
I have 3 similar SQL queries that each will bring back 1 record with
I have a couple of LINQ to SQL queries that I feel take a
I have several Oracle queries that perform well when run through SQL*PLUS. However when
I have an SSIS package that queries data from a view using an SQL

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.