I need to write an SQL query to take either from one of two column's data(based on whichever is available and not null) and append it to a static text into another column within the same table.
Can anybody tell me how to write this?
Example Data :
ID Type Barcode Serial No Location
1 Test ABCD 1234 LOC1
2 Test EFGH NULL LOC2
3 Test NULL 5678 LOC3
4 Test NULL NULL LOC1
Final Data Reqd in Format
ID Type Barcode Serial No Location
1 Test ABCD 1234 LOC1-ABCD (Append barcode if its not null)
2 Test EFGH NULL LOC2-EFGH (Append barcode if its not null)
3 Test NULL 5678 LOC3-5678 (Append serial no since barcode is null)
4 Test NULL NULL LOC1 (Both r Null keep loc as it is)
Please help me on it....really stuck on this :(
Database is Oracle 10.
Supra
Update 1 :
Thanks a lot Marco for your help....the location field only needs to updated in the table after appending the barcode/serial no from the same table into location field. Your edited query is not working :(...please let me know if I need to give some more info/data.
Final Update :
Shesek's Answer worked perfect :D...you are the man :)...Thanks a ton :D