How to search duplicate records and order by columns from MSSQL Table without primary key?

StackOverflow https://stackoverflow.com/questions/5855548

  •  27-10-2019
  •  | 
  •  

I getting top 20 record from SQL Table
There is a column State in My MS SQL Table there are some numeric data,

In my case I skipped numeric records from C# function after I am getting duplicate results of City and Country,
for example 'Los Angeles','Venezuela' coming duplicates if I skipped state numeric data
How to remove/delete duplicate entries if the 'state' field contains numeric using SQL scripts

also I want to get top records from the Country 'United states' in Descending order
I wrote query as below:-

  Declare @sCity varchar(100),
    SELECT     Top 20  City,State,Country   
    FROM 
        [dbo].[Locations]  
    WHERE   
        City like  @sCity+'%'   
    ORDER BY    
            [dbo].[AllWorldLocations].Country DESC,         
            [dbo].[AllWorldLocations].STATE ASC, 
            [dbo].[AllWorldLocations].City ASC


my table is like that enter image description here


I want to get records descending order by country

Los Angeles             California   United States
Los Angeles             Texas        United States
Los Angeles Subdivision    Texas        United States
有帮助吗?

解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top