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 2005 Forums
 Transact-SQL (2005)
 SQL Distinct Column Combinations

Author  Topic 

crishna
Starting Member

5 Posts

Posted - 2008-10-29 : 13:00:09
Hi,

Row Column LabelText TextBoxLabelText CheckBoxText FormCellTypeF7A8AE42 9C790FB2 Command and Display Label
F7A8AE42 B34B7D87 Command and Display Label
88CC0121 9C790FB2 Date: TextField
88CC0121 B34B7D87 Date: TextField
EDE01A0E 9C790FB2 Job Name TextField
EDE01A0E B34B7D87 Job Name TextField
GHFFGRYT HJRTYEt6 testSample CheckBox
GHFFGRYT HJRTYUER testSample CheckBox

I am searching how to write a query to get below data

Row Column LabelText TextBoxLabelText CheckBoxText FormCellTypeF7A8AE42 9C790FB2 Command and Display Label
88CC0121 9C790FB2 Date: TextField
EDE01A0E 9C790FB2 Job Name TextField
GHFFGRYT HJRTYEt6 testSample CheckBox


How can I arrive at Distict rows when there are rows with repeating text in last 4 Columns

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-29 : 13:05:25
[code]SELECT *
FROM
(
SELECT ROW_NUMBER() OVER(PARTITION BY Row ORDER BY Column) AS Seq,*
FROM Table
)t
WHERE Seq=1[/code]
Go to Top of Page

crishna
Starting Member

5 Posts

Posted - 2008-10-29 : 14:02:20
hey thanks for the reply,

SELECT * FROM( SELECT ROW_NUMBER() OVER(PARTITION BY Row ORDER BY Column) AS Seq,* FROM #celltmp) WHERE Seq=1)

it gives me a error. Could you please tell me where I am doing wrong
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-29 : 14:09:45
missing alias your table name "t", just copy exactly what visakh16 posted.

Make sure that you are using sql 2005 or later
Go to Top of Page

crishna
Starting Member

5 Posts

Posted - 2008-10-29 : 14:24:18
works like a charm.

thanks guys
Go to Top of Page
   

- Advertisement -