I have a question on how to sort data using sql. For that I made up a simple example to illustrate my problem.
if object_id('MyTable', 'U') is not null drop table dbo.MyTable;
create table MyTable
(
country varchar(10) not null
, town varchar( 10 ) not null
, amount int not null
)
insert into MyTable values
( 'US', 'NYC', 100 )
, ( 'US', 'BAL', 150 )
, ( 'US', 'WAS', 200 )
, ( 'CA', 'MON', 100 )
, ( 'CA', 'TOR', 150 )
, ( 'CA', 'VAN', 200 )
How can I sort the data in a sense the all “countries are sorted by the amount in descending order AND that the towns in alphabetical order for each country.
Thanks,
Christian
I think that this should do it: