[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

query in sql server

In sql server I have the following table:
ID                 Name
aaa             desc of aaa
bbb             desc1 of bbb
bbb            desc2 of bbb
ccc            desc of ccc
I want to create a new table or a query that for each ID will show the first Name that exist.
How do I do it?
Thankyou
Anat
0
ANAT2403
Asked:
ANAT2403
1 Solution
 
MOA81Commented:
Dear ANAT2403

what do you mean by first name

as for the query

select ID,Name from Table

??

but what do u mean by first name

can you make an example of the above table
0
 
HuyBDCommented:
select ID,(select top 1 from table as t where t.ID=table.ID) as name
from table
group by ID

replace table with your table name

HuyBD;
0
 
ANAT2403Author Commented:
hi HuyBD,
very good execp one correction instead of  top 1
it shoul be top 1 name
thankyou
anat
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now