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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:54:52+00:00 2026-05-26T23:54:52+00:00

In SQL Server, I’ve the following design: Is it 100% sure that the first

  • 0

In SQL Server, I’ve the following design:

enter image description here

Is it 100% sure that the first condition from the OR statement in a JOIN will be executed first ? So that the following SQL statement will result in the green result?

SELECT P.Name, D.Percentage
FROM Personnel P
JOIN Department D ON
  P.Dep_Code = D.Code AND
  (P.SubDep_Code = D.SubCode OR D.SubCode = '*')
  • 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-05-26T23:54:53+00:00Added an answer on May 26, 2026 at 11:54 pm

    Is it 100% sure that the first condition from the OR statement in a
    JOIN will be executed first ?

    No. There is no guaranteed order of evaluation and even if there where the entire expression would still evaluate to the same value and would not influence what rows are matched in the join.

    Your query will give this result:

    Name       Percentage
    ---------- -----------
    P-A        100
    P-A        20
    P-A        80
    P-B        100
    

    I guess you are looking for something like this.

    select P.Name,
           coalesce(D1.Percentage, D2.Percentage) as Percentage
    from Personnel as P
      left outer join Department as D1
        on P.Dep_Code = D1.Code and
           P.SubDep_Code = D1.SubCode
      left outer join Department as D2
        on P.Dep_Code = D2.Code and
           D2.SubCode = '*'
    where coalesce(D1.Percentage, D2.Percentage) is not null
    

    You can try the queries here using SQL Server 2008. https://data.stackexchange.com/stackoverflow/qt/118492/

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

Sidebar

Related Questions

SQL Server 2005: The following view SELECT CONVERT(VARCHAR(20), keyedtimestamp, 101) as KeyedDate FROM TMSSTATFILE_STATS
SQL Server 2005. Is there a sql query that will return a text field
SQL Server 2000 Standard, Windows 2003 My coworker removed 'BUILTIN\Administrators' group from SQL Server
SQL Server 2005 query is as follows...... SELECT ClgId FROM IdMaker_DB WHERE Course =
SQL Server 2008: Sorry for the possibly non-informative title but I'm not sure quite
SQL Server Management studio generated value of datatype Date into following string: CAST(0x38320B00 AS
SQL Server 2008 database design problem. I'm defining the architecture for a service where
SQL SERVER, I'm working with a table that uses a guid for the key
SQL server 2008 sp2 I am a beginner and finding that XQuery syntax especially
SQL Server 2005 I have a table containing the following: - [order_id] [index_1] 600020001

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.