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
 Transact-SQL (2000)
 Select query

Author  Topic 

sagavb
Starting Member

18 Posts

Posted - 2009-05-29 : 05:43:34
Hi friends,

I am new to SQL. Can anyone help on this?

Table name: test
name path
a 'C:'
b 'D:'
c 'E:'
a 'D:'
c 'F:'

In the above table, a and c values are repeated.
I just want to find out the first occurences of the path for duplicate values

output must be as mentioned below;
-----------------------------------
name path
a 'C:'
c 'E:'


Regards
Saga

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-29 : 05:45:32
[code]
select name, min(path)
from yourtable
group by name
having count(*) > 1
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sagavb
Starting Member

18 Posts

Posted - 2009-05-29 : 05:46:58
Thanks a lot

quote:
Originally posted by khtan


select name, min(path)
from yourtable
group by name
having count(*) > 1



KH
[spoiler]Time is always against us[/spoiler]



Go to Top of Page

sagavb
Starting Member

18 Posts

Posted - 2009-05-29 : 05:52:58
Hi,

Table name: test
name path
a 'C:'
b 'D:'
c 'E:'
a 'D:'
c 'F:'

In the above table, a and c values are repeated.
I just want to delete the repeated rows without using group by clause

output must be as mentioned below;
-----------------------------------
name path
b 'D:'


Regards
Saga

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-29 : 05:55:51
Why the restriction of NOT using the GROUP BY statement?
Is this homework question?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sagavb
Starting Member

18 Posts

Posted - 2009-05-29 : 05:56:34
Yes.

But, is this possible?


quote:
Originally posted by Peso

Why the restriction of NOT using the GROUP BY statement?
Is this homework question?


E 12°55'05.63"
N 56°04'39.26"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-29 : 05:59:00
Yes, but will be more difficult and involves loops and things.

Let me talk to your professor


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -