Wednesday, 28 February 2018

Write sql query to get every 3rd records from the employee table

CREATE TABLE Employee
(
    ID                      int identity(1,1),
    EmployeeID      int NOT NULL,
    Mob                   varchar(11),
    JoiningDate       datetime,
    [Name]             varchar(50)
)

insert into Employee(EmployeeID,Mob,JoiningDate,Name) values(101,'9569375463',getdate(),'Ashish'),(102,'8010019068',getdate(),'Pankaj'),(103,'123456789',getdate(),'Radha'),(104,'12345',getdate(),'krishna'),(105,'565859595',getdate(),'Kushal'),(106,'6664444444',getdate(),'krishna'),(107,'8899999',getdate(),'kunal'),(108,'12345',getdate(),'amit'),(109,'565859595',getdate(),'ajay'),(110,'6664444444',getdate(),'avinash'),(111,'8899999',getdate(),'avin'),(112,'12345',getdate(),'kartik')



Sql query to get every 3rd records-

select * from Employee where id%3 =0



No comments:

Post a Comment