Solved

query in sql server

Posted on 2007-04-10
3
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to import SQL 2000 database to SQL 2014 5 183
How to use TOP 1 in a T-SQL sub-query? 14 54
Urgent help needed! Unable to to paste in query designer 29 58
Sql Server group by 10 58
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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