Below is the table structure of tables a,b,c,d and x
write a query to find id, i am expecting this can be done using case statement but not sure how to put it in query.