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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:06:07+00:00 2026-06-15T03:06:07+00:00

Query: SELECT * FROM station Output: id | stationname | total ————————- 1 |

  • 0

Query:

SELECT * FROM station

Output:

id | stationname | total
-------------------------
 1 | Khar        | 5
 2 | SantaCruz   | 3
 3 | Sion        | 2
 4 | VT          | 1
 5 | newFort     | 3
 6 | Bandra      | 2
 7 | Worli       | 1
 8 | Sanpada     | 3
 9 | Joe         | 2
10 | Sally       | 1
11 | Elphiston   | 2
12 | Currey Road | 1

Is it possible to display all the record but with a condition that will display particular record at 1st position and below then display rest all records

E.g. my where condition is

where id=10

Desired output:

id | stationname | total
-------------------------
10 | Sally       | 1
 1 | Khar        | 5
 2 | SantaCruz   | 3
 3 | Sion        | 2
 4 | VT          | 1
 5 | newFort     | 3
 6 | Bandra      | 2
 7 | Worli       | 1
 8 | Sanpada     | 3
 9 | Joe         | 2
11 | Elphiston   | 2
12 | Currey Road | 1

Any idea, hint will be appreciated

  • 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-15T03:06:08+00:00Added an answer on June 15, 2026 at 3:06 am

    You can union two different query using UNION ALL like this:

    SELECT * FROM Station WHERE ID=10
    UNION ALL
    SELECT * FROM Station WHERE ID<>10
    

    See this SQLFiddle


    Update (related to returned order is undefined)

    If you see the execution plan of both queries (using UNION and UNION ALL), the query using UNION will sort the result while the query using UNION ALL will not sort the result. see execution plan of both queries in this SQLFiddle.

    Execution Plan using UNION query:

    enter image description here

    Execution Plan using UNION ALL query:

    enter image description here

    I found this from SQL SERVER – Introduction and Example of UNION and UNION ALL

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

Sidebar

Related Questions

I have folowing sql query select sta_name Station,count(factory_name) as factories from gps1 group by
I have a query: SELECT ID, Name, Distance FROM Station GROUP BY 'Distance approximation'
select station_id,count(case_id) from emer_complaint group by station_id Above query returning the correct result. But,
this query SELECT * FROM tblContracts LEFT JOIN tblPartys ON tblContracts.id = tblPartys.Contract_id INNER
this is the mysql query SELECT * FROM users AS up JOIN users AS
i have this sql query select * from table where name like ? but
Here's my query SELECT * FROM wp_postmeta WHERE meta_value LIKE '.$_POST['username'].' AND meta_value LIKE
I have a mysql query Select * from tbl_schoolphotos where Filename like 'glasshouse_1_%' order
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
This is my current query: select serial_number, order_number, (select TOP 1 PRODUCT_ID from PS_ORD_LINE

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.