Please could you advise? Can we use if else condition in where clause of oracle?
I should execute such example:
We should select all files with name "Car". And if there is no 'car', i should select "Motorbike".
in other words, it should work like this: IF(name = 'Car') then smth related to Car else if(name = 'Car' does not exist) then smth related to Motorbike.
We have multiple tables: One table is related to above one is .
A, B, C, ..., Vehicle.
in query, I want to do like this:
SELECT a.(some field), b.(some field), c.(some field), vehicle.(some field)
FROM a, b, c, ..., vehicle
WHERE
if vehicle = 'CAR' THEN a.(some field) = vehicle.(some field)
else if vehicle = 'CAR' does not exist, then a.(some field) = vehicle(MOTOR).(some field)
Table Vehicle (idV, idAll, nameVehicle, vehicleProductionDate):
1. 1, 1ABC, Car, 26-Apr-15
2. 2, 1ABC, Car, 26-Apr-16
3. 3, 1ABC, Car, 26-Apr-17
4. 4, 1ABC, Bike, 26-Apr-18
5. 5, 1ABC, Motorbike, 26-Apr-18
6. 6, 2ABC, Bike, 26-Apr-15
7. 7, 2ABC, Bike, 26-Apr-16
8. 8, 2ABC, Bike, 26-Apr-17
9. 9, 2ABC, Motorbike, 26-Apr-15
10. 10, 2ABC, Motorbike, 26-Apr-17
11. 11, 2ABC, Motorbike, 26-May-16
Table Step (idS, idAll, nameStep, logStepDate):
1. 1, 1ABC, Testing, 25-Apr-17
2. 2, 2ABC, Logging, 25-Apr-17
Table Company: (idC, idAll, nameCompany):
1. 1, 1ABC, Jeep
2. 2, 2ABC, Ford
And my final result, when executing, should contain all 3 tables data:
1, 1ABC, Jeep, Testing, 25-Apr-17, Car, 26-Apr-16
2, 2ABC, Ford, Logging, 25-Apr-17, Motorbike, 26-May-16
If you see there, log date should be equal or greater than vehicle Production Date and if there are several vehicles which are less, then we should take the latest one of less vehicles.