SELECT country,city
FROM customers
GROUP BY country
ORDER BY city DESC

Answers were Sorted based on User's Feedback



SELECT country,city FROM customers GROUP BY country ORDER BY city DESC ..

Answer / prajakta

this is right coz here order by clause is at the end of
query...

Is This Answer Correct ?    21 Yes 3 No

SELECT country,city FROM customers GROUP BY country ORDER BY city DESC ..

Answer / nitin

is right or not

Is This Answer Correct ?    18 Yes 4 No

SELECT country,city FROM customers GROUP BY country ORDER BY city DESC ..

Answer / manoj pandey

This is wrong because there is no aggregate function in the
query when a group by clause is used.

The above query could be like:

1. SELECT country, count(city)
2. FROM customers
3. GROUP BY country
4. ORDER BY country DESC

* Correction at line 1 & 4.

Is This Answer Correct ?    12 Yes 9 No

SELECT country,city FROM customers GROUP BY country ORDER BY city DESC ..

Answer / rod sohrabi

It will only return 1 row per country and will display only the city that is reverse alphabetical order

Is This Answer Correct ?    3 Yes 2 No

SELECT country,city FROM customers GROUP BY country ORDER BY city DESC ..

Answer / vardhan rao

This Query will delete the duplicate values in GROUP BY clause

Is This Answer Correct ?    3 Yes 5 No

Post New Answer

More MySQL Interview Questions

how to display only 4 records from a table based on a condition for ex i have a table called products in that nid,prodname are fields i want to display only any 4 records of perticular product plz tell me

6 Answers  


How do I assign a variable in mysql?

0 Answers  


Is mariadb faster than mysql?

0 Answers  


What is Database?

2 Answers  


What are the differences between mysql vs sql server?

0 Answers  






How to run a sql statement?

0 Answers  


How do I uninstall mysql connector?

0 Answers  


How to drop an existing view in mysql?

0 Answers  


What is the difference between now() and current_date()?

0 Answers  


How do I find users in mysql?

0 Answers  


What is the difference between myisam dynamic and myisam static in mysql?

0 Answers  


How to get a list of all tables in a database?

0 Answers  


Categories