keithwilson1
asked on
Merge two rows in SQL
Assuming I have a table containing the following information:
FK | Field1 | Field2
=====================
1 | ABC | *NULL*
2 | *NULL* | DEF
is there a way I can perform a select on the table to get the following
FK | Field1 | Field2
=====================
2 | ABC | DEF
Thanks
FK | Field1 | Field2
=====================
1 | ABC | *NULL*
2 | *NULL* | DEF
is there a way I can perform a select on the table to get the following
FK | Field1 | Field2
=====================
2 | ABC | DEF
Thanks
ASKER
GROUP BY
FK;
Group by FK value 1 and 2
Giving a new row with 2 in the FK field
The table will have 450 rows. 1 and 2 in the FK field with a StudentID. Sorry for not specifying the StudentID earlier.
StudentID |FK | Field1 | Field2
=====================
A0203340 |1 | ABC | *NULL*
A0203340 |2 | *NULL* | DEF
is there a way I can perform a select on the table to get the following
StudentID |FK | Field1 | Field2
=====================
A0203340 |2 | ABC | DEF
FK;
Group by FK value 1 and 2
Giving a new row with 2 in the FK field
The table will have 450 rows. 1 and 2 in the FK field with a StudentID. Sorry for not specifying the StudentID earlier.
StudentID |FK | Field1 | Field2
=====================
A0203340 |1 | ABC | *NULL*
A0203340 |2 | *NULL* | DEF
is there a way I can perform a select on the table to get the following
StudentID |FK | Field1 | Field2
=====================
A0203340 |2 | ABC | DEF
ASKER
Grouping is done by StudentID and FX.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select max(fk) fk, max(field1) field1, max(field2) field2 from yourtable