Written By:- Isha Malhotra
Our Website:-Tech Altum
Use of percent(%) in Top command in SQL Server
For example:-
Our Website:-Tech Altum
Use of percent(%) in Top command in SQL Server
In my last article I discussed about the
top command. In this article I am showing how to use percent with top command.
I am taking the table same as I used in my last article.
Use of percent in Top command
If I
Want to select 2 rows from the top then I will write the following query:-
select top 2 * from prod_rep
But we can also select
Data in percentage (%) using top command. Using percentage it will show the row
Accordingly. For example if table contains 4 rows and I select 50% then it will
Show 2 rows.
For example:-
Take the following
Table to show this example:-
Figure 1
This table contain the 8 rows and I run the
following queries using top command:-
select top 50percent * from prod_rep;
it will
show the following output:-
Figure 2
According to the percentage which you will
Give in the query it will show the output.
thanx mam its a new thimg for me.....
ReplyDeleteI am very very impressed with your blog, I hope you will have more blogs or more articles to bring to readers. You are doing a very good job.
ReplyDeleteVBSPU BSc 3rd year result 2022
MJPRU BSc 3rd year result 2022
Uniraj BSc 3rd year result 2022