Solved

query in sql server

Posted on 2007-04-10
3
236 Views
Last Modified: 2010-03-19
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
Comment
Question by:ANAT2403
3 Comments
 
LVL 8

Expert Comment

by:MOA81
ID: 18881089
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
 
LVL 17

Accepted Solution

by:
HuyBD earned 500 total points
ID: 18881117
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
 

Author Comment

by:ANAT2403
ID: 18881170
hi HuyBD,
very good execp one correction instead of  top 1
it shoul be top 1 name
thankyou
anat
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now