Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 16th, 2004, 11:03 PM
ajiss78 ajiss78 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 ajiss78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old June 17th, 2004, 12:58 AM
astrocanis astrocanis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 14 astrocanis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to astrocanis
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.

Reply With Quote
  #3  
Old June 17th, 2004, 08:21 PM
ajiss78 ajiss78 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 ajiss78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks astrocanis, i had tried ur SQL and its work !!... Thanks Again

Best Regards,...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Combine 2 column into one in select statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway