In the list of countries that should be displayed in alphabetical order, you need to place the USA at the top of the list. How do you do this?
I replied by saying that I would have a table structure so that the US would have id-0. The remaining countries are listed in alphabetical order.
So when I exit the table, I will do " SELECT CountryName from tableOfCountries ORDER by ID "
I'm not sure the interviewer wanted to hear that. Therefore, I proposed another option for populating an array of countries from the USA as the first element. Then the remaining elements will be populated from the query result set.
"SELECT CountryName FROM tableOfCountries WHERE countryName != 'US' ORDER by COUNTRY_NAME".
This ensures that the USA will not be selected twice.
The interviewer was not satisfied with this option. So he asked me if I have another option. Then I said a text file on a web server with a list of values.
Do you have other options you might think about?
abhi
source share