all groups > sql server dts > march 2005 >
You're in the

sql server dts

group:

SQL problem


Re: SQL problem Tom Moreau
3/13/2005 9:08:36 AM
sql server dts:
Try:

select
left (Code, 7) as Code
, Name
from
MyTable o
where
o.Code =
(
select
min (i.Code)
from
MyTable i
where
left (i.Code, 7) = left (o.Code, 7)
)

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
..
[quoted text, click to view]
Hi All

Have a table with this structure

Code Name

100000010 Project A - area 1
100000011 Projekt A - area x
200000010 Project B - area 1
200000011 Projekct - area x
...

From this I would like to create a new table with this structure

1000000 Project A - area 1
2000000 Project B - area 1

I need to get left(code,7) but my problem is how to select one of the name s
and attaching this to the 7 digit code. In my example below I just chose the
first Name I encounter - I cannot
take x characteres because this differ.

But is it possible to select the name from the first...if so - how ?

/Michael V.

SQL problem Michael Vardinghus
3/13/2005 1:42:21 PM
Hi All

Have a table with this structure

Code Name

100000010 Project A - area 1
100000011 Projekt A - area x
200000010 Project B - area 1
200000011 Projekct - area x
...

From this I would like to create a new table with this structure

1000000 Project A - area 1
2000000 Project B - area 1

I need to get left(code,7) but my problem is how to select one of the name s
and attaching this to the 7 digit code. In my example below I just chose the
first Name I encounter - I cannot
take x characteres because this differ.

But is it possible to select the name from the first...if so - how ?

/Michael V.

Re: SQL problem Michael Vardinghus
3/14/2005 10:15:28 PM
Sounds like the way to go ...

Thanks Tom

[quoted text, click to view]

AddThis Social Bookmark Button