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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:44:38+00:00 2026-05-23T08:44:38+00:00

I came across a query today, SELECT col1,’yes’ as col2 FROM myTable WHERE col2=TRUE

  • 0

I came across a query today,

SELECT col1,'yes' as col2  FROM myTable  
   WHERE col2=TRUE  
UNION  
SELECT col1,'no' as col2 FROM mytable  
   WHERE col2=FALSE  
ORDER BY 1,2  

I thought it would order by first column and then second but since a UNION is involved I am a bit unsure can someone explain the exact meaning of this query

  • 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-23T08:44:39+00:00Added an answer on May 23, 2026 at 8:44 am

    SQL Server will union the results together (which is an implied select distinct) and then order the results by col1 then col2. In a union query, you can put an ORDER BY on the final select, which will sort the final result.

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

Sidebar

Related Questions

I came across writing the query in differnt ways like shown below Type-I SELECT
While researching Oracle Analytics, I came across this query: select an_id, a_date, min(a_date) over
Today I came across a quirky behavior from what looked like a simple SQL
I came across a mysql query that looks like this: SELECT SUM(some_amount*(some_field!=90)*(some_date < '2011-04-22'))
I just came across a query that does an inner join on a non-distinct
Came across something like this today, and was wondering if there was an equivalent
I came across the following URL today: http://www.sfgate.com/cgi-bin/blogs/inmarin/detail??blogid=122&entry_id=64497 Notice the doubled question mark at
I came across linq query which ends in (...).ToList().AsQueryable(). I know the use of
It could be a stupid query, but i came across of this query multiple
I came across a question today of search efficiency for large sets today and

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.