Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-08-16 : 09:29:41
|
| Dror writes "Hi I have the following table with existing rowsCITY_NAME----------CITY_CODENEW-YORK-----------10LONDON-------------11AMSTERDAM----------12AMSTERDAM----------12AMSTERDAM----------12LONDON-------------11Each CITY_NAME corresponds to a unique CITY_CODEI need to get a list of each city and the count of how many times it shows up in the table.To make the query fast I GROUP BY CITY_CODE and NOT CITY_NAME as follows:SELECT CITY_CODE, COUNT(*) FROM table GROUP BY CITY_CODEI want the result to be (without getting the name of the city from another table)NEW-YORK ----- 1AMSTERDAM----- 3LONDON---------2Can I get the desired result from a query that will do the comparisons on the CITY_ID (FASTER!!!) an not on the CITY_NAMEThanks" |
|
|
|
|
|