sql - How do I transform table- see example? -


if suggests better question title, change it, that's best come with.

i using sql server 2005

is there way transform table 'table_1' 'table_2' using sql.

edit: don't want create new table, want represent in query 'table_2'

table_1:

   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 want if have table_3:

table_3:

id    m     3 b     4 c     8 

i query against table_2 (transformed table_1) this:

select table_3.id table_3 table_2 m between x , y , z = true 

i'll answer following questions head of time: 1. can not change table design, nor did design table. 3. have reason not process on client side c# or language.

thanks

try self-join:

select t1.a, min(t2.a), t1.b table_1 t1     inner join table_1 t2 on t2.a > t1.a group t1.a, t1.b 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -