Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

probably an easy way to do this using DISTINCT

$
0
0

Hi I am trying to create a stored procedure (SQL query) that returns all columns of a table but only want the rows that are DISTINCT for one column only.  That is I have a column TESTINT with integers like 1,2,2,2,3,3,4,4,5,6,6,6,6 ect.  I only want the first row for 1,2,3,4,5,6 and want all the columns in the tabe for these rows.  I can use DISTINCT to  only return the column TESTINT but need the data in the other columns as well.  I tried a subquery but the subquery was returning more than 1 record. 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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