SQL SELECT TOP

Learn how to use SQL SELECT TOP statement with the tutorial and Examples. Find out how to retrieve top rows in a table with SQL SELECT TOP statement.

You can retrive all the top rows of a table using the (*). Retrieve only the selected column rows from the top of the table. You just need to put the number of top rows you want to fetch.

How to Use SQL SELECT TOP Statement to Get Rows From Top

There are many types whose syntax given below to get rows from the top of the table. You can retrive all the data or you can get only the selected column data from the top of the table.

Syntax1: Select All Column Record From The Top of the Table.

The above syntax displays the rows of all the column of a table. You have to specify only the table name from where you want to retrieve the rows of all the column from top of the table.

Syntax2: Retrive Rows From Selected Column in Table.

The above syntax select the rows of only the specified columns. You have to enter the column names for which you want to retrive the rows and the table name from where you want to fetch the rows of columns.

Syntax3: Retrive Selected Column Rows in a Table With WHERE Condition.

In addition to all the above-given syntax, you can use the conditional statement to fetch the required data and count.

Parameter Descriptions

Sr.No Parameter Name Description
1 column_name Enter required column names from where you want to retrieve the rows from the table. You can also use the symbol (*) to get the top rows from all the columns of a table.
2 tablename Specify the table name from where you want to fetch the rows of specified columns from the top.
3 condition Specify the condition the fetch only required rows from the top of the table.
4 number Specify the number of rows you want to retrieve from the top of the table.

You must also learn.

Reference