Hello,
I am an Oracle SQL newbie and wondered if it was possible to query a database column and if a condition is met select these column if not select a different column?
Background: We have a legacy database that's been recently migrated, now during this transitioning period all new entries will use the same logical name but use totally different primary keys (IDs).
So, we have 2 tables one table primary key starting with "C" and the other table primary key starts with "P", I can retrieve host names in the "C" table which does contents "C" & "P" primary keys but since "P" table columns does not line-up with "C" table there is no way I can retrieve other relevant details if the primary key begins with "P".
The SQL query below is what I want to achieve but do not know enough too write the correct SQL statements.
I am lost and not sure if this is possible, any help would be greatly appreciated.
Thanks in advance,
Don
Select i.TICKET_ID_, i.PROBLEM_ID, t.INV_ID
If t.INV_ID = "P%" then
Select p.name, p.SYSTEM, p.IMPACT, p.MODEL_NUMBER
Else
Select t.COMPONENT, c.OPERATING_SYSTEM, c.ESCALATION_IMPACT, c.MODEL
End if
FROM MANAGEMENT i
JOIN Module t
ON i.ticket_id_ = t.ticket_id_
LEFT JOIN HARDWARE c
ON t.INV_ID = c.INV_ID
LEFT JOIN COMPUTER_SYSTEM p
ON t.COMPONENT = p.name