Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

How to get top 10 of a column in SQL

$
0
0

Am using the following script 

Text
select top 10 with ties name,empsizval
from dbo.empdb
where releaseno = '202'
Order by empsizval

The goal is to have it to retrieve the records with the 10 highest values based on empsizval. Empsizval is the estimated number of employees at a given location. Attached is a sample data set. When I run the script above, I get null values for empsizval. Also, if I use the following it returns incorrect values

Text
select top 10 empsizval
from empdb
where releaseno = 202

The schema for the table is

name varchar(35)

privgovsta char(1)

empsizval numeric (9,0)

empsizrng varchar(1)


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>