Solved

query in sql server

Posted on 2007-04-10
3
244 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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