Following are my sql table
create table sales_employee
(
name varchar(50),
territory varchar(50),
sales_amount int
)
And Follwing are the records
name territory sales_amount
A X 100
B X 200
C X 200
D X 300
E X 400
F Y 300
G Y 300
H Y 500
I Y 600
J Z 200
K Z 700
So i need to find top 5 salary amount from above records but the condition is without using TOP keyword..
How i get that output without using TOP?
Rajeesh MenothPosted Jun 28, 2016, 7:13 AM
barathi rajaPosted Jun 28, 2016, 6:56 AM
Vinoth BalasubramanianPosted Jun 17, 2016, 7:14 AM
FROM sales_employee
ORDER BY NAME ASC
OFFSET 0 ROWS
FETCH FIRST 5 ROWS ONLY
FROM (
SELECT *,
ROW_NUMBER() OVER (ORDER BY name) AS RowNumber
FROM sales_employee
) temp
WHERE RowNumber <= 5