SELECT TOP 1 FROM Table_Name
This will select 1 row from table
SELECT TOP 1* FROM Table_Name (Select all columns of 1st row)
SELECT TOP 2* FROM Table_Name (Select first two rows of table)
SELECT TOP 50 PERCENT * FROM Table_Name (Select 50 % rows from table)
LIKE OPERATOR
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
IF a column name CITY from Persons table contains Kanpur, Delhi , NewDelhi , Kannauj , Nagar values then If you want to select city name starts from K then :-
SELECT * FROM Persons
WHERE CITY LIKE 'k%'
this will retrieve Kanpur , Kannauj.
If you want to select city name ends from i then :-
SELECT * FROM Persons
WHERE CITY LIKE '%i'
IF you want to select a city which has particular format like Select a city which has 'elh' pattern
SELECT * FROM Persons
WHERE City LIKE '%elh%'
this will retrieve Delhi , NewDelhi.
If you dont want to select a city which has particular format like 'elh'
SELECT * FROM Persons
WHERE City NOT LIKE '%elh%'
This will select 1 row from table
SELECT TOP 1* FROM Table_Name (Select all columns of 1st row)
SELECT TOP 2* FROM Table_Name (Select first two rows of table)
SELECT TOP 50 PERCENT * FROM Table_Name (Select 50 % rows from table)
LIKE OPERATOR
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
IF a column name CITY from Persons table contains Kanpur, Delhi , NewDelhi , Kannauj , Nagar values then If you want to select city name starts from K then :-
SELECT * FROM Persons
WHERE CITY LIKE 'k%'
this will retrieve Kanpur , Kannauj.
If you want to select city name ends from i then :-
SELECT * FROM Persons
WHERE CITY LIKE '%i'
IF you want to select a city which has particular format like Select a city which has 'elh' pattern
SELECT * FROM Persons
WHERE City LIKE '%elh%'
this will retrieve Delhi , NewDelhi.
If you dont want to select a city which has particular format like 'elh'
SELECT * FROM Persons
WHERE City NOT LIKE '%elh%'