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
 General SQL Server Forums
 New to SQL Server Programming
 Using Distinct and * in select

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-02 : 08:05:39
Bahrudeen writes "Hi..
hw to use Select query for both distinct and *

(eg) select * , distinct(building_id) from g_building where
(condition)

i want all information with distinct building id..
give a solution

advance thanx..."

Kristen
Test

22859 Posts

Posted - 2006-03-02 : 08:07:43
Hi Bahrudeen, Welcome to SQL Team!

If, say, there are two rows for a given builing_id what do you want the SELECT * to display?

Because if you display all the columns, assuming that there are some differences, it can't really be displayed as one row!

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-02 : 08:14:04
Sounds that you are trying to suppress the column if duplicated
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-03-02 : 09:07:14
You need to use scalar functions....and SELECT * is a bad idea

http://weblogs.sqlteam.com/brettk/archive/2004/04/22/1272.aspx



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
   

- Advertisement -