Amazon Interview Question
Software Engineer / Developersselect c1.name from customer c1 where c1.dateOfBirth = (select min(c2.dateOfBirth) from customer c2)
I still did not get it. Why are we to worry about dob column. Say I, age 24 open acct in Bank on Aug-07-2001 and Mr. B, age 50 open acct on jan-01-2009. I shall still be the oldest customer and not the eldest as the question asks for. Plus to it if it happens that there are more than one people opening the acct on the same date and are of same age, the timestamp data type shall help returning the one who has opened earlier.
select name from customer where a=min(customer ID);
I think this query will fetch the right data from the table
No. Fetching the oldest customer based on customerId seems incorrect to me.
This condition may fail when we have data from two different bank/retail outlet recently merged. (real world scenario)
From my point of view. account open date should be right field to find the oldest customer as mentioned in few of the earlier post.
- m@}{ April 20, 2011