I have one query in SQL Server output,
Suppose i have one table (Ex.StudentMaster) having some fields-No unique constraints. For Ex. RollNumber and Name The table h
You can use DISTINCT which return's distinct combination's of columns.
SELECT DISTINCT RollNo, Name
FROM mytable
Any row is a third row :-)
create table test
(
n int,
name varchar(30)
);
insert into test values(1,'yoko'),(1,'yoko'),(1,'yoko');
select ROW_NUMBER() over(order by name) as ordinal, * from test;
Deleting the "third" row :-)
with a as
(
select ROW_NUMBER() over(order by name) as ordinal, * from test
)
delete from a where a.ordinal = 3
Deleting the last row:
with a as
(
select ROW_NUMBER() over(order by name) as ordinal, * from test
)
delete from a where a.ordinal = (select MAX(ordinal) from a)