SQL – Top and Percent (highest and lowest values selection)

Spread the love

SQL-Top – define rows limit to view/get for query result , also top/bottom values in the table/query.

SQL-Percent – % wise define rows limit to view/get for query result , also top/bottom values in the table/query.
Example – 25 rows are 25% of 100 rows.

 

PRODUCT TABLE

S_NOPRODUCTMONTHYEARQTYSALES
1NIKEDEC2016107599
2REEBOKJAN2014903500
3FILAFEB201786000
4PUMAJAN2015165000
5NULLAPR201252500

 

TOP

SELECT 2 HIGHEST SALES VALUES

SELECT TOP 2 *
FROM PRODUCT
ORDER BY SALES DESC

Result

S_NOPRODUCTMONTHYEARQTYSALES
1NIKEDEC2016107599
3FILAFEB201786000

PERCENT

TOP 50 % ROWS OF TOTAL ROWS

SELECT TOP 50 PERCENT *
FROM PRODUCT

Result

S_NOPRODUCTMONTHYEARQTYSALES
1NIKEDEC2016107599
2REEBOKJAN2014181200
3FILAFEB201786000

 

 

difference between Percent and Top search keyword
sql Percent vs Top search keyword
Percent vs Top in SQL search keyword
Write Percent and Top in SQL search keyword
Percent in sql search keyword
sql Percent search keyword
Percent query writing search keyword
write query as Percent search keyword
query writing Percent search keyword
structure of Percent sql search keyword
easy method to write Percent query search keyword
remove complexity of query writing by Percent search keyword
Technics to write Percent query search keyword
structure of Percent query sql search keyword
Top in sql search keyword
sql Top search keyword
Top query writing search keyword
write query as Top search keyword
query writing Top search keyword
structure of Top sql search keyword
easy method to write Top query search keyword
remove complexity of query writing by Top search keyword
Technics to write Top search keyword
structure of Top query sql search keyword