Showing posts with label top command. Show all posts
Showing posts with label top command. Show all posts

Friday, 19 April 2013

Use of percent(%) in Top command in SQL Server

Written By:- Isha Malhotra
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.

Sunday, 7 April 2013

Use of Top command in SQL Server

Written By:- Isha Malhotra
Our Website:-Tech Altum

Use of Top command in SQL Server

The top command is used to select the top value from the table. We have to give the number of row with the top command.

For Example:-

Consider the following table as example in which it shows the prod_year, dept and no_of_prod.



Figure 1

Suppose in this table if you want to select top 2 rows then you will use the top command as follows:-

select top 2 * from prod_rep;