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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:27:40+00:00 2026-05-19T16:27:40+00:00

If someone suggests a better question title, I will change it, but that’s the

  • 0

If someone suggests a better question title, I will change it, but that’s the best I could come up with.

I am using SQL Server 2005

Is there a good way to transform table ‘table_1’ to ‘table_2’ using SQL.

Edit: I don’t necessarily want to create a new table, I just want to represent it in a query as so that it will look like ‘table_2’

table_1:

 a   b     
 1   TRUE   
 2   FALSE  
 4   TRUE   
 7   FALSE  
 9   TRUE   
10   FALSE  

table_2:

x    y   z
1    2   TRUE
2    4   FALSE
4    7   TRUE
7    9   FALSE
9   10   TRUE

The reason I want to do this is so that if I have table_3:

table_3:

id    m
a     3
b     4
c     8

I would like to query against table_2 (transformed table_1) like this:

SELECT table_3.id
FROM table_3
FROM table_2
WHERE m BETWEEN x AND y
AND z = TRUE

I’ll answer the following questions a head of time:
1. I can not change the table design, nor did I design the table.
3. I have good reason not to process this on client side with c# or another language.

thanks

  • 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-19T16:27:41+00:00Added an answer on May 19, 2026 at 4:27 pm

    Try a self-join:

    select t1.a, min(t2.a), t1.b
    from table_1 t1
        inner join table_1 t2 on t2.a > t1.a
    group by t1.a, t1.b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone suggest a better approach for a string comparison among two strings with
I am using SQL Server 2008. A while back, I asked the question should
I'm not sure how best to word the Title of this, so if someone
Some will object that this is not a programming question. I'm willing to defend
Could someone suggest me a tool to find circular dependencies? I tried with a
Can someone suggest me some JAVA string library for JAVA ME that includes basic
I recently posted this question on the r-help mailing list but got no answers,
I thought the C/C++ vs C#/Java performance question was well trodden, meaning that I'd
I know this is not a technical question, but this is something I believe
iv got a really simple javascript question. Ill be using query for parts of

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.