Gossamer Forum
Home : General : Databases and SQL :

SQL query

Quote Reply
SQL query
Hi all,

I have the following table:

Code:
Name1 : City1 : ...
Name2 : City1 : ...
Name3 : City1 : ...
Name1 : City2 : ...
Name5 : City1 : ...
Code:

...but now I would like to create one view of this table with by default only the name, and when there are two or more matches of a cname: name (cityname)

So:

Code:
Name1 (City1) : ...
Name1 (City2) : ...
Name2 : ...
Name3 : ...
Name5 : ...

I tried, but as you can see I don't know how to referernce ????

Code:

SELECT TOP 100 PERCENT

uname as Name,
Fullname = (select count(*) from database as x where x.uname = ????),
ucity as City

FROM database
Quote Reply
Re: [cK] SQL query In reply to
Hello cK, 'group by' may provide a simple solution or not depending on your desired results.

So look on google for sql and 'group by' or buy a book on sql.

or may be 'distinct' might be looked at in your sql query.

Hope this helps. A library card is also useful.

See Ya

Cornball
Quote Reply
Re: [cornball] SQL query In reply to
Group by or distinct won't work due to the fact it's already big query. It's more a query in a query (I think).