Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Returning a recordset that has distinct values in a certain column

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-13 : 12:21:17
Bob writes "Without using cursors or "SELECT TOP", how do you return a recordset with multiple columns that have unique (distinct) values in a particular column? In other words, I want to get single non-repeating values in a particular column, but at the same time return the whole row. The query will run on SQL Server 7.0 running in SQL Server 6.5 compatibility mode, so "SELECT TOP" is not supported."

Nazim
A custom title

1408 Posts

Posted - 2002-04-14 : 00:23:38
I dont quite understand what you are looking for, but whatever i could make out you can achieve it this way


Set rowcount 1
select distict * from tablename
order by columnname1,columname2.........


or


select columname1,columname2,columname3.....
from tablename
group by columnname1,columnname2,columname3...


HTH

--------------------------------------------------------------


Edited by - Nazim on 04/14/2002 01:28:36
Go to Top of Page

Lavos
Posting Yak Master

200 Posts

Posted - 2002-04-14 : 23:08:45
As Nazim says, it's very unclear exactly what you are wanting.

There's just too much missing data to try to guess what it is that you really wanting to know, so it might help if you post a short snippet of data with the result set that you expect.

(If you post the DDL for creating the sample table, it'd probably help to.)

----------------------
"O Theos mou! Echo ten labrida en te mou kephale!"
Go to Top of Page
   

- Advertisement -