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 2005 Forums
 Transact-SQL (2005)
 Simple Query

Author  Topic 

mapidea
Posting Yak Master

124 Posts

Posted - 2009-02-03 : 00:06:55
Is this the right query for

“Show me a list of cities, in alphabetical order, where our vendors are located, and include the names of the vendors we work with in each city.”

select distinct vendorname, vendorcity
from vendors
Order by vendorcity asc

Thanks

mapidea
Posting Yak Master

124 Posts

Posted - 2009-02-03 : 00:08:48
The above query returns vendorcity as many times it is there.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-03 : 00:18:39
if vendors are 4 in one city it will show the vendorname,vendorcity 4 times only
if u want only cities then use
select distinct vendorcity from vendors order by vendorcity asc
Go to Top of Page

mapidea
Posting Yak Master

124 Posts

Posted - 2009-02-03 : 00:23:38
Thanks
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-03 : 00:51:18
quote:
Originally posted by mapidea

Thanks



welcome
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-03 : 09:25:38
quote:
Originally posted by mapidea

Is this the right query for

“Show me a list of cities, in alphabetical order, where our vendors are located, and include the names of the vendors we work with in each city.”

select distinct vendorname, vendorcity
from vendors
Order by vendorcity asc

Thanks


why dont you check this before posting as a question here?
Go to Top of Page
   

- Advertisement -