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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:41:41+00:00 2026-05-13T08:41:41+00:00

I have a SQL Report driven by a query that sorts it in ascending

  • 0

I have a SQL Report driven by a query that sorts it in ascending order of some numerical value. But the user wants two particular rows of data, which happen to appear at different ordinal positions in the query results, to be juxtaposed. Is there a way to do this, either through the report’s driving SQL or the .rdl file itself?

  • 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-13T08:41:42+00:00Added an answer on May 13, 2026 at 8:41 am

    Just add another calculated expression as the first order by Expression, which puts those two values ahead of all others…

    Select [Other stuff]
    From Table
    Order By Case colName 
              When first_val then 0
              When second_val then 0
              else 1 End,
          colName 
    

    or, EDIT (to include @astander’s suggestion)

    Select [Other stuff]
    From Table
    Order By Case 
             When colName In (first_Val, second_Val)
             Then 0 else 1 End,
          colName 
    

    and another Edit, to put second_val immediately after first_Val…

    Select [Other stuff]
    From Table
    Order By Case 
             When colName < first_Val And colName <> secondVal Then 0
             When colName = first_Val Then 1
             When colName = secondVal Then 2 
             Else 3 End,
          colName 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a report that is driven by a sql query that looks like
I have SQL Server 2005 Report that takes a parameter in a query string
I have an SQL Server Reporting Services (SSRS) report, that uses a view. That
I have an SQL query with a nested join: SELECT rh.host, rh.report, COUNT(results.id), COUNT(results_2.id),
I am using Microsoft SQL Server 2008 Report Builder . I have designed some
I have a report that I created in SQL Server Reporting Services 2008. I
I have a simple user production report where daily quotas are tracked. The sql
I have some questions about building reports in Report builder 3.0 OR SQL Server
I have a SQL Report that insists on printing an extra blank page at
I have a SQL Server report project in VS 2005 that won't preview one

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.