Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How can I make this selection

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-12-09 : 04:56:29

Hai
In my customer table I have two field name and location
How can I select name and location whose name is 'Ramu' and location is diffrent

ie if the table contains values such as

Name location
Ramu India
Ramu USA
Ramu India
John USA
John India

How can I make a query such that it results

Ramu India
Ramu USA

Thanks and Regards
Anu Palavila

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-12-09 : 06:08:28
hi try this

select distinct name+' '+location from your_table where name='ramu'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 10:56:47
no need of concatenating, just use

select distinct name,location from your_table where name='ramu'

Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2008-12-13 : 07:08:49
You Can also try these statements

SELECT NAME,location FROM your_table WHERE NAME = 'ramu' GROUP BY name,location

SELECT NAME,location FROM your_table GROUP BY name,location HAVING name = 'ramu'


Jai Krishna
Go to Top of Page
   

- Advertisement -