How to convert two rows to one
Index
‹
SQL Server
‹
SQL Server Developer
Author
Message
hexathioorthooxalate
Posted: Thu Feb 01 07:54:39 CST 2007
Top
SQL Server Developer >> How to convert two rows to one
hi
i need convert two rows to one row and insert into another table with
the same structure.
i have
ID |something | P1 | P2 | P3 | P4 | date_A | date_B |
1 | abc | 1 | 0 | 0 | 0 | NULL | 1/1/2007|
2 | abc | 1 | 2 | 3 | 4 | 2/1/2007 | NULL |
the result
ID |something | P1 | P2 | P3 | P4 | date_A | date_B |
1 | abc | 1 | 2 | 3 | 4 | 2/1/2007| 1/1/2007|
the values for conditions are col.something and col.P1
pls help
SQL Server142
markc600
Posted: Thu Feb 01 07:54:39 CST 2007
Top
SQL Server Developer >> How to convert two rows to one Maybe this?
select min(ID) as ID,
something,
P1,
max(P2) as P2,
max(P3) as P3,
max(P4) as P4,
max(date_A) as date_A,
max(date_B) as date_B
from mytable
group by something,P1
Index
‹
SQL Server
‹
SQL Server Developer