|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Combine 2 column into one in select statement
Hi there,
I would like to ask anyone who can solve problem in my query for different condition, i want to do a select statement that combine 2 column in a row into single column as example: "select StopMachineDates dates,Schedule_Dates dates ,work_type,action" if the problem type is breakdown the dates should grab from the StopMachineDates and if the problem type is corrective the dates should grab from Schedule_Dates, so the output should become like this : Dates : Worktype: Action: 6/1/2004 BreakDown Repair Engine 6/10/2004 Corrective Service Do Anyone can help me to solve this?? Thank You |
|
#2
|
|||
|
|||
|
what you want is based on a decode:
select decode(column_i_am_basing_on, value1, column1, value2, column2) date, column_i_am_basing_on from mytable the decode acts a lot like an if statement...the above would read if column_i_am_basing_on is value1, then return the value in column1, if it is value2, then return the value in column2 from mytable note that decode is not limited to checking two values...i am not sure what the limit is, but it is more than i have ever used. |
|
#3
|
|||
|
|||
|
Thanks astrocanis, i had tried ur SQL and its work !!... Thanks Again
Best Regards,... |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Combine 2 column into one in select statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|