tuzojazz Posted October 13, 2007 Share Posted October 13, 2007 Hi:suposse I have this table named "Employees" Employees-----------------------Emloyee----Country-------------------------Geroge-------GermanyJohn-----------ItalySteve----------MexicoJim-------------GermanyBrian-----------GermanyRichard---------ItalyI want to get the countries in order that are repeated like thisGermanyItalyMexicohow can I do this query?Thanks!! Link to comment Share on other sites More sharing options...
Synook Posted October 13, 2007 Share Posted October 13, 2007 You mean likeGeroge-------GermanyJohn-----------ItalySteve----------MexicoJim-------------GermanyRichard---------ItalyBrian-----------GermanyorGeroge-------GermanyBrian-----------GermanyJim-------------GermanyJohn-----------ItalyRichard---------ItalySteve----------MexicoThere is no way to perform the former that I can think of, but the latter can be done through ORDER BY SELECT Employee, Country FROM Employees ORDER BY Country Link to comment Share on other sites More sharing options...
justsomeguy Posted October 13, 2007 Share Posted October 13, 2007 If you just want to get the list of countries you can do this: SELECT DISTINCT Country FROM Employees Link to comment Share on other sites More sharing options...
Synook Posted October 14, 2007 Share Posted October 14, 2007 is that what he meant - oops Link to comment Share on other sites More sharing options...
tuzojazz Posted October 15, 2007 Author Share Posted October 15, 2007 If you just want to get the list of countries you can do this:SELECT DISTINCT Country FROM Employees I want to get the countries in order where are the most of the employeesanother exampleGeroge-------MexicoJohn-----------ItalySteve----------MexicoJim-------------MexicoRichard---------ItalyBrian-----------GermanyI want to get this orderMexicoItalyGermany Link to comment Share on other sites More sharing options...
justsomeguy Posted October 15, 2007 Share Posted October 15, 2007 SELECT COUNT(Employee) AS num, Country FROM Employees GROUP BY Country ORDER BY num DESC Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.