Hi I have the following table
Driver
| Id | vehicleId | Power |
| -------- | --------------|-------------- |
| 123 | 2221 |112 |
| 124 | 2222 |111 |
Vehicle
vehicleId| VehicleAvl|
| -------- | -------------- |
| 2221| Yes|
| 2222| Yes|
VehicleCountry
Id| vehicleId| VehicleField| VehicleValue |
| -------| -------- | -------------- | -------------- |
| 1 | 2221| Residence Country| USA|
| 2| 2221| Registered Country| USA|
| 3 | 2221| Available Country| CAN|
| 4| 2222| Residence Country| USA|
From the above i Need to write a simple select query which will fetch whehter the vehicle residence country belongs to usa or not
I dont need any columns to be returned rather than simple Select 1
I have only the Driver table ID as input so How can i write a query for the requirement
SELECT 1
FROM Driver IES, Vehicle d1,
where
IES.id= :GID and d1.vehicleId= IES.vehicleId
And (SELECT vehiclevalue AS RESIDENCE_COUNTRY
FROM VehicleCountry t2
where t2.vehicleId=d1.vehicleId
AND t2.vehiclefield= 'RESIDENCE COUNTRY'
) DR
AND (IES.POWER IS NOT NULL
OR DR.RESIDENCE_COUNTRY != 'USA'
OR DR.RESIDENCE_COUNTRY IS NULL)